[llvm-commits] [llvm] r54653 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/mul.ll
Chris Lattner
sabre at nondot.org
Mon Aug 11 15:06:06 PDT 2008
Author: lattner
Date: Mon Aug 11 17:06:05 2008
New Revision: 54653
URL: http://llvm.org/viewvc/llvm-project?rev=54653&view=rev
Log:
Implement support for simplifying vector comparisons by 0.0 and 1.0 like we
do for scalars. Patch contributed by Nicolas Capens
This also generalizes the previous xforms to work on long double, now that
isExactlyValue works for long double.
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
llvm/trunk/test/Transforms/InstCombine/mul.ll
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=54653&r1=54652&r2=54653&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Aug 11 17:06:05 2008
@@ -2480,10 +2480,17 @@
// "In IEEE floating point, x*1 is not equivalent to x for nans. However,
// ANSI says we can drop signals, so we can do this anyway." (from GCC)
- // We need a better interface for long double here.
- if (Op1->getType() == Type::FloatTy || Op1->getType() == Type::DoubleTy)
- if (Op1F->isExactlyValue(1.0))
- return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
+ if (Op1F->isExactlyValue(1.0))
+ return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
+ } else if (isa<VectorType>(Op1->getType())) {
+ if (isa<ConstantAggregateZero>(Op1))
+ return ReplaceInstUsesWith(I, Op1);
+
+ // As above, vector X*splat(1.0) -> X in all defined cases.
+ if (ConstantVector *Op1V = dyn_cast<ConstantVector>(Op1))
+ if (ConstantFP *F = dyn_cast_or_null<ConstantFP>(Op1V->getSplatValue()))
+ if (F->isExactlyValue(1.0))
+ return ReplaceInstUsesWith(I, Op0);
}
if (BinaryOperator *Op0I = dyn_cast<BinaryOperator>(Op0))
@@ -11636,3 +11643,4 @@
return new InstCombiner();
}
+
Modified: llvm/trunk/test/Transforms/InstCombine/mul.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/mul.ll?rev=54653&r1=54652&r2=54653&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/mul.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/mul.ll Mon Aug 11 17:06:05 2008
@@ -1,7 +1,5 @@
; This test makes sure that mul instructions are properly eliminated.
-;
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep mul
-; END.
define i32 @test1(i32 %A) {
%B = mul i32 %A, 1 ; <i32> [#uses=1]
@@ -78,3 +76,18 @@
ret i32 %e
}
+; PR2642
+define internal void @test13(<4 x float>*) {
+ load <4 x float>* %0, align 1
+ mul <4 x float> %2, < float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00 >
+ store <4 x float> %3, <4 x float>* %0, align 1
+ ret void
+}
+
+define internal void @test14(<4 x float>*) {
+ load <4 x float>* %0, align 1
+ mul <4 x float> %2, zeroinitializer
+ store <4 x float> %3, <4 x float>* %0, align 1
+ ret void
+}
+
More information about the llvm-commits
mailing list