[PATCH] D41322: [WIP][InstCombine] Missed optimization in math expression: squashing sqrt functions
Hal Finkel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 20:13:20 PST 2017
hfinkel added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:731
+ // sqrt(a) * sqrt(b) -> sqrt(a * b)
+ if (AllowReassociate) {
----------------
spatel wrote:
> What if sqrt(a) or sqrt(b) has another use besides the multiply? I don't think we want to do the transform in that case. Either way, please add a test for that kind of example.
I agree, we should have ->hasOneUse() checks here.
================
Comment at: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:740
+ Value *Opnd1 = I1->getOperand(0);
+ Builder.setFastMathFlags(I.getFastMathFlags());
+ Value *FMulVal = Builder.CreateFMul(Opnd0, Opnd1);
----------------
Needs
BuilderTy::FastMathFlagGuard Guard(Builder);
above this.
https://reviews.llvm.org/D41322
More information about the llvm-commits
mailing list