summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-06-15 05:26:55 +0000
committerChris Lattner <sabre@nondot.org>2007-06-15 05:26:55 +0000
commitf14e5175ed50e7d7aff6791af83a70fb2a8299f1 (patch)
treef6c851dcf7e9fcb9631497af86305800dc6f6b1a /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parentadd977670f7facc68cd3a50b763fe9df113d506e (diff)
downloadbcm5719-llvm-f14e5175ed50e7d7aff6791af83a70fb2a8299f1.tar.gz
bcm5719-llvm-f14e5175ed50e7d7aff6791af83a70fb2a8299f1.zip
delete some obviously dead vector operations, which deletes a few thousand
operations from Duraids example. llvm-svn: 37582
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 01fcfabeba4..bab6616deda 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -3245,8 +3245,10 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
return &I;
} else {
if (ConstantVector *CP = dyn_cast<ConstantVector>(Op1)) {
- if (CP->isAllOnesValue())
+ if (CP->isAllOnesValue()) // X & <-1,-1> -> X
return ReplaceInstUsesWith(I, I.getOperand(0));
+ } else if (isa<ConstantAggregateZero>(Op1)) {
+ return ReplaceInstUsesWith(I, Op1); // X & <0,0> -> <0,0>
}
}
@@ -3714,7 +3716,14 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
if (SimplifyDemandedBits(&I, APInt::getAllOnesValue(BitWidth),
KnownZero, KnownOne))
return &I;
+ } else if (isa<ConstantAggregateZero>(Op1)) {
+ return ReplaceInstUsesWith(I, Op0); // X | <0,0> -> X
+ } else if (ConstantVector *CP = dyn_cast<ConstantVector>(Op1)) {
+ if (CP->isAllOnesValue()) // X | <-1,-1> -> <-1,-1>
+ return ReplaceInstUsesWith(I, I.getOperand(1));
}
+
+
// or X, -1 == -1
if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
@@ -4107,6 +4116,8 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
if (SimplifyDemandedBits(&I, APInt::getAllOnesValue(BitWidth),
KnownZero, KnownOne))
return &I;
+ } else if (isa<ConstantAggregateZero>(Op1)) {
+ return ReplaceInstUsesWith(I, Op0); // X ^ <0,0> -> X
}
if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
OpenPOWER on IntegriCloud