[llvm] [InstCombine] Fix 0.0 / x -> 0 folds when the divisor may be zero (PR #202482)
Justin Lebar via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 18 13:36:03 PDT 2026
================
@@ -2731,12 +2731,22 @@ Value *InstCombinerImpl::SimplifyDemandedUseFPClass(Instruction *I,
SimplifyDemandedFPClass(I, 1, RHSDemandedMask, KnownRHS, SQ, Depth + 1))
return I;
+ bool ResultNotNan = (DemandedMask & fcNan) == fcNone;
+ bool ResultNotInf = (DemandedMask & fcInf) == fcNone;
+
+ // Replacing 0/x with a zero is only valid when the divisor can't be
+ // (logical) zero, since 0/0 is NaN -- unless NaN results aren't demanded. A
+ // subnormal divisor can flush to zero under a flushing denormal mode.
+ bool DivisorNonZeroOrNanOK =
----------------
jlebar wrote:
done, thank you for the review.
https://github.com/llvm/llvm-project/pull/202482
More information about the llvm-commits
mailing list