Fix a bug in InstCombine where we failed to preserve fast math flags when optimizing...
authorOwen Anderson <resistor@mac.com>
Thu, 16 Jan 2014 20:59:41 +0000 (20:59 +0000)
committerOwen Anderson <resistor@mac.com>
Thu, 16 Jan 2014 20:59:41 +0000 (20:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199424 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
test/Transforms/InstCombine/fmul.ll

index 6c34b1bf56631f587407aba26e3ec29b0f846eee..94461c5f84a2cbbd92dec40ba57b45756f293d92 100644 (file)
@@ -525,8 +525,11 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
       Value *N1 = dyn_castFNegVal(Opnd1, IgnoreZeroSign);
 
       // -X * -Y => X*Y
-      if (N1)
-        return BinaryOperator::CreateFMul(N0, N1);
+      if (N1) {
+        Value *FMul = Builder->CreateFMul(N0, N1);
+        FMul->takeName(&I);
+        return ReplaceInstUsesWith(I, FMul);
+      }
 
       if (Opnd0->hasOneUse()) {
         // -X * Y => -(X*Y) (Promote negation as high as possible)
index 71b7138b644c2c77df0c11530b2db802dd302485..0b4a90d88fa3de2d492d2bc9d4a25faac27bcff8 100644 (file)
@@ -24,10 +24,10 @@ define float @test2(float %x) {
 define float @test3(float %x, float %y) {
   %sub1 = fsub float -0.000000e+00, %x
   %sub2 = fsub float -0.000000e+00, %y
-  %mul = fmul float %sub1, %sub2
+  %mul = fmul fast float %sub1, %sub2
   ret float %mul
 ; CHECK-LABEL: @test3(
-; CHECK: fmul float %x, %y
+; CHECK: fmul fast float %x, %y
 }
 
 ; (0.0 - X) * (0.0 - Y) => X * Y
@@ -104,4 +104,3 @@ define float @test9(float %x) {
 ; CHECK: fsub
 }
 
-