[llvm] r199424 - Fix a bug in InstCombine where we failed to preserve fast math flags when optimizing an FMUL expression.
Owen Anderson
resistor at mac.com
Thu Jan 16 12:59:41 PST 2014
Author: resistor
Date: Thu Jan 16 14:59:41 2014
New Revision: 199424
URL: http://llvm.org/viewvc/llvm-project?rev=199424&view=rev
Log:
Fix a bug in InstCombine where we failed to preserve fast math flags when optimizing an FMUL expression.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/trunk/test/Transforms/InstCombine/fmul.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=199424&r1=199423&r2=199424&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Thu Jan 16 14:59:41 2014
@@ -525,8 +525,11 @@ Instruction *InstCombiner::visitFMul(Bin
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)
Modified: llvm/trunk/test/Transforms/InstCombine/fmul.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fmul.ll?rev=199424&r1=199423&r2=199424&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fmul.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fmul.ll Thu Jan 16 14:59:41 2014
@@ -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
}
-
More information about the llvm-commits
mailing list