mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-08 19:25:47 +00:00
InstCombine: Make the (fmul X, -1.0) -> (fsub -0.0, X) transform handle vectors too.
PR18532. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199553 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -425,17 +425,15 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
|
|||||||
if (Instruction *NV = FoldOpIntoPhi(I))
|
if (Instruction *NV = FoldOpIntoPhi(I))
|
||||||
return NV;
|
return NV;
|
||||||
|
|
||||||
ConstantFP *C = dyn_cast<ConstantFP>(Op1);
|
|
||||||
|
|
||||||
// (fmul X, -1.0) --> (fsub -0.0, X)
|
// (fmul X, -1.0) --> (fsub -0.0, X)
|
||||||
if (C && C->isExactlyValue(-1.0)) {
|
if (match(Op1, m_SpecificFP(-1.0))) {
|
||||||
Instruction *RI = BinaryOperator::CreateFSub(
|
Constant *NegZero = ConstantFP::getNegativeZero(Op1->getType());
|
||||||
ConstantFP::getNegativeZero(C->getType()),
|
Instruction *RI = BinaryOperator::CreateFSub(NegZero, Op0);
|
||||||
Op0);
|
|
||||||
RI->copyFastMathFlags(&I);
|
RI->copyFastMathFlags(&I);
|
||||||
return RI;
|
return RI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConstantFP *C = dyn_cast<ConstantFP>(Op1);
|
||||||
if (C && AllowReassociate && C->getValueAPF().isFiniteNonZero()) {
|
if (C && AllowReassociate && C->getValueAPF().isFiniteNonZero()) {
|
||||||
// Let MDC denote an expression in one of these forms:
|
// Let MDC denote an expression in one of these forms:
|
||||||
// X * C, C/X, X/C, where C is a constant.
|
// X * C, C/X, X/C, where C is a constant.
|
||||||
|
@@ -104,3 +104,12 @@ define float @test9(float %x) {
|
|||||||
; CHECK: fsub
|
; CHECK: fsub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; PR18532
|
||||||
|
define <4 x float> @test10(<4 x float> %x) {
|
||||||
|
%mul = fmul <4 x float> %x, <float -1.0, float -1.0, float -1.0, float -1.0>
|
||||||
|
ret <4 x float> %mul
|
||||||
|
|
||||||
|
; CHECK-LABEL: @test10(
|
||||||
|
; CHECK-NOT: fmul
|
||||||
|
; CHECK: fsub
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user