================
@@ -2331,6 +2331,136 @@ Value
*InstCombinerImpl::SimplifyDemandedUseFPClass(Instruction *I,
FPClassTest ValidResults = DemandedMask & Known.KnownFPClasses;
return getFPClassConstant(VTy, ValidResults, /*IsCanonicalizing=*/true);
}
+ case Instruction::FDiv: {
+ Value *X = I->getOperand(0);
+ Value *Y = I->getOperand(1);
+ if (X == Y && isGuaranteedNotToBeUndef(X, SQ.AC, CxtI, SQ.DT, Depth + 1)) {
+ // If the source is 0, inf or nan, the result is a nan
+
+ Value *IsZeroOrNan = Builder.CreateFCmpFMF(
+ FCmpInst::FCMP_UEQ, I->getOperand(0), ConstantFP::getZero(VTy), FMF);
+
+ Value *Fabs =
+ Builder.CreateUnaryIntrinsic(Intrinsic::fabs, I->getOperand(0), FMF);
+ Value *IsInfOrNan = Builder.CreateFCmpFMF(
+ FCmpInst::FCMP_UEQ, Fabs, ConstantFP::getInfinity(VTy), FMF);
+
+ Value *IsInfOrZeroOrNan = Builder.CreateOr(IsInfOrNan, IsZeroOrNan);
----------------
dtcxzyw wrote:
Use is.fpclass instead. When is_zero/is_inf gets simplified, InstCombine will
convert it into the canonical form `fcmp fabs(x), inf/0`.
https://github.com/llvm/llvm-project/pull/175946
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits