[llvm] [InstCombine] Transform high latency, dependent FSQRT/FDIV into FMUL (PR #87474)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed May 8 08:50:54 PDT 2024
================
@@ -1796,6 +1941,30 @@ static Instruction *foldFDivSqrtDivisor(BinaryOperator &I,
return BinaryOperator::CreateFMulFMF(Op0, NewSqrt, &I);
}
+Value *convertFSqrtDivIntoFMul(CallInst *CI, Instruction *X,
+ SmallSetVector<Instruction *, 2> &R1,
+ SmallSetVector<Instruction *, 2> &R2,
+ Value *SqrtOp, InstCombiner::BuilderTy &B) {
+
+ // 1. synthesize tmp1 = 1/a and replace uses of r1
+ B.SetInsertPoint(X);
+ Value *Tmp1 =
+ B.CreateFDivFMF(ConstantFP::get(R1[0]->getType(), 1.0), SqrtOp, R1[0]);
----------------
arsenm wrote:
You do not have any tests showing !fpmath metadata is preserved. This is separate from the FastMathFlags (and I believe is getting dropped in this code as written). I would like to see preservation where there is fpmath metadata set on each of the sqrt, div, and both
https://github.com/llvm/llvm-project/pull/87474
More information about the llvm-commits
mailing list