Fix an instance where we would drop fast math flags when performing an fdiv to recipr...
authorOwen Anderson <resistor@mac.com>
Thu, 16 Jan 2014 21:07:52 +0000 (21:07 +0000)
committerOwen Anderson <resistor@mac.com>
Thu, 16 Jan 2014 21:07:52 +0000 (21:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199425 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 94461c5f84a2cbbd92dec40ba57b45756f293d92..f61d82340b586ea99d3265402d83d8c19f087934 100644 (file)
@@ -1050,8 +1050,10 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {
     }
 
     // X / C => X * 1/C
-    if (Instruction *T = CvtFDivConstToReciprocal(Op0, Op1C, AllowReciprocal))
+    if (Instruction *T = CvtFDivConstToReciprocal(Op0, Op1C, AllowReciprocal)) {
+      T->copyFastMathFlags(&I);
       return T;
+    }
 
     return 0;
   }
index 1edbc5ecd60b5da318074d2828de3d5b4b755535..c3aabd7866693e83f8aa2541d08c3080bc935885 100644 (file)
@@ -23,3 +23,11 @@ define float @test3(float %x) nounwind readnone ssp {
 ; CHECK-LABEL: @test3(
 ; CHECK-NEXT: fdiv float %x, 0x36A0000000000000
 }
+
+define float @test4(float %x) nounwind readnone ssp {
+  %div = fdiv fast float %x, 8.0
+  ret float %div
+
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: fmul fast float %x, 1.250000e-01
+}