[llvm] r291611 - InstCombine: fdiv -x, -y -> fdiv x, y
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 10 15:08:54 PST 2017
Author: arsenm
Date: Tue Jan 10 17:08:54 2017
New Revision: 291611
URL: http://llvm.org/viewvc/llvm-project?rev=291611&view=rev
Log:
InstCombine: fdiv -x, -y -> fdiv x, y
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=291611&r1=291610&r2=291611&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Tue Jan 10 17:08:54 2017
@@ -1443,6 +1443,16 @@ Instruction *InstCombiner::visitFDiv(Bin
}
}
+ Value *LHS;
+ Value *RHS;
+
+ // -x / -y -> x / y
+ if (match(Op0, m_FNeg(m_Value(LHS))) && match(Op1, m_FNeg(m_Value(RHS)))) {
+ I.setOperand(0, LHS);
+ I.setOperand(1, RHS);
+ return &I;
+ }
+
return nullptr;
}
Modified: llvm/trunk/test/Transforms/InstCombine/fdiv.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fdiv.ll?rev=291611&r1=291610&r2=291611&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fdiv.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fdiv.ll Tue Jan 10 17:08:54 2017
@@ -49,3 +49,21 @@ define float @test6(float %x, float %y,
; CHECK-NEXT: fmul fast
; CHECK-NEXT: fdiv fast
}
+
+; CHECK-LABEL @fdiv_fneg_fneg(
+; CHECK: %div = fdiv float %x, %y
+define float @fdiv_fneg_fneg(float %x, float %y) {
+ %x.fneg = fsub float -0.0, %x
+ %y.fneg = fsub float -0.0, %y
+ %div = fdiv float %x.fneg, %y.fneg
+ ret float %div
+}
+
+; CHECK-LABEL @fdiv_fneg_fneg_fast(
+; CHECK: %div = fdiv fast float %x, %y
+define float @fdiv_fneg_fneg_fast(float %x, float %y) {
+ %x.fneg = fsub float -0.0, %x
+ %y.fneg = fsub float -0.0, %y
+ %div = fdiv fast float %x.fneg, %y.fneg
+ ret float %div
+}
More information about the llvm-commits
mailing list