[llvm] r199425 - Fix an instance where we would drop fast math flags when performing an fdiv to reciprocal multiply transformation.
Owen Anderson
resistor at mac.com
Thu Jan 16 13:07:52 PST 2014
Author: resistor
Date: Thu Jan 16 15:07:52 2014
New Revision: 199425
URL: http://llvm.org/viewvc/llvm-project?rev=199425&view=rev
Log:
Fix an instance where we would drop fast math flags when performing an fdiv to reciprocal multiply transformation.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/trunk/test/Transforms/InstCombine/fdiv.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=199425&r1=199424&r2=199425&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Thu Jan 16 15:07:52 2014
@@ -1050,8 +1050,10 @@ Instruction *InstCombiner::visitFDiv(Bin
}
// 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;
}
Modified: llvm/trunk/test/Transforms/InstCombine/fdiv.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fdiv.ll?rev=199425&r1=199424&r2=199425&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fdiv.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fdiv.ll Thu Jan 16 15:07:52 2014
@@ -23,3 +23,11 @@ define float @test3(float %x) nounwind r
; 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
+}
More information about the llvm-commits
mailing list