mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 12:19:53 +00:00
InstCombine: fdiv -x, -y -> fdiv x, y
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291611 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ada6595a52
commit
3aa9c7e336
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user