Skip to content

Commit

Permalink
Avoid using v_mul_legacy in normalize with more conditions
Browse files Browse the repository at this point in the history
When NSZ, NoInfs, or NoNaNs is not specified, avoid using v_mul_legacy
since it is not IEEE compliant.
  • Loading branch information
amdrexu authored and qiaojbao committed Jan 2, 2024
1 parent f8bcfbd commit 784bf0c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lgc/builder/ArithBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,8 @@ Value *BuilderImpl::CreateNormalizeVector(Value *x, const Twine &instName) {
Value *result = nullptr;
if (x->getType()->getScalarType()->isFloatTy()) {
// Make sure a FP32 zero vector is normalized to a FP32 zero vector, rather than NaNs.
if (!getFastMathFlags().noSignedZeros()) {
// When NSZ is not specified, we avoid using fmul_legacy since the sign of the input is dropped.
if (!getFastMathFlags().noSignedZeros() || !getFastMathFlags().noInfs() || !getFastMathFlags().noNaNs()) {
// When NSZ, NoInfs, or NoNaNs is not specified, we avoid using fmul_legacy since it is not IEEE compliant.
auto zero = ConstantFP::get(getFloatTy(), 0.0);
auto isZeroDot = CreateFCmpOEQ(dot, zero);
rsq = CreateSelect(isZeroDot, zero, rsq);
Expand Down

0 comments on commit 784bf0c

Please sign in to comment.