[llvm] r199553 - InstCombine: Make the (fmul X, -1.0) -> (fsub -0.0, X) transform handle vectors too.
Benjamin Kramer
benny.kra at googlemail.com
Sat Jan 18 08:43:14 PST 2014
Author: d0k
Date: Sat Jan 18 10:43:14 2014
New Revision: 199553
URL: http://llvm.org/viewvc/llvm-project?rev=199553&view=rev
Log:
InstCombine: Make the (fmul X, -1.0) -> (fsub -0.0, X) transform handle vectors too.
PR18532.
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=199553&r1=199552&r2=199553&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Sat Jan 18 10:43:14 2014
@@ -425,17 +425,15 @@ Instruction *InstCombiner::visitFMul(Bin
if (Instruction *NV = FoldOpIntoPhi(I))
return NV;
- ConstantFP *C = dyn_cast<ConstantFP>(Op1);
-
// (fmul X, -1.0) --> (fsub -0.0, X)
- if (C && C->isExactlyValue(-1.0)) {
- Instruction *RI = BinaryOperator::CreateFSub(
- ConstantFP::getNegativeZero(C->getType()),
- Op0);
+ if (match(Op1, m_SpecificFP(-1.0))) {
+ Constant *NegZero = ConstantFP::getNegativeZero(Op1->getType());
+ Instruction *RI = BinaryOperator::CreateFSub(NegZero, Op0);
RI->copyFastMathFlags(&I);
return RI;
}
+ ConstantFP *C = dyn_cast<ConstantFP>(Op1);
if (C && AllowReassociate && C->getValueAPF().isFiniteNonZero()) {
// Let MDC denote an expression in one of these forms:
// X * C, C/X, X/C, where C is a constant.
Modified: llvm/trunk/test/Transforms/InstCombine/fmul.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fmul.ll?rev=199553&r1=199552&r2=199553&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fmul.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fmul.ll Sat Jan 18 10:43:14 2014
@@ -104,3 +104,12 @@ define float @test9(float %x) {
; 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
+}
More information about the llvm-commits
mailing list