diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2017-01-10 23:08:54 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2017-01-10 23:08:54 +0000 |
commit | fdb78f8baee78909c8003d5dff92dee76d50c6d0 (patch) | |
tree | c63ac64436718a1cf3c0073b0bb2145401a638d5 /llvm | |
parent | 20d252c4c1bb982555457cd8df72cfd28523da27 (diff) | |
download | bcm5719-llvm-fdb78f8baee78909c8003d5dff92dee76d50c6d0.tar.gz bcm5719-llvm-fdb78f8baee78909c8003d5dff92dee76d50c6d0.zip |
InstCombine: fdiv -x, -y -> fdiv x, y
llvm-svn: 291611
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 10 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/fdiv.ll | 18 |
2 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index ac64671725f..04f03844ea6 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -1443,6 +1443,16 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) { } } + 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; } diff --git a/llvm/test/Transforms/InstCombine/fdiv.ll b/llvm/test/Transforms/InstCombine/fdiv.ll index af6a2401a8f..9a10c452335 100644 --- a/llvm/test/Transforms/InstCombine/fdiv.ll +++ b/llvm/test/Transforms/InstCombine/fdiv.ll @@ -49,3 +49,21 @@ define float @test6(float %x, float %y, float %z) nounwind readnone ssp { ; 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 +} |