From: Chris Lattner Date: Fri, 15 Jun 2007 05:26:55 +0000 (+0000) Subject: delete some obviously dead vector operations, which deletes a few thousand X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=041a6c90484643da1222b83f9e7da4e62de1e661;p=oota-llvm.git delete some obviously dead vector operations, which deletes a few thousand operations from Duraids example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37582 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 01fcfabeba4..bab6616deda 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -3245,8 +3245,10 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { return &I; } else { if (ConstantVector *CP = dyn_cast(Op1)) { - if (CP->isAllOnesValue()) + if (CP->isAllOnesValue()) // X & <-1,-1> -> X return ReplaceInstUsesWith(I, I.getOperand(0)); + } else if (isa(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(Op1)) { + return ReplaceInstUsesWith(I, Op0); // X | <0,0> -> X + } else if (ConstantVector *CP = dyn_cast(Op1)) { + if (CP->isAllOnesValue()) // X | <-1,-1> -> <-1,-1> + return ReplaceInstUsesWith(I, I.getOperand(1)); } + + // or X, -1 == -1 if (ConstantInt *RHS = dyn_cast(Op1)) { @@ -4107,6 +4116,8 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { if (SimplifyDemandedBits(&I, APInt::getAllOnesValue(BitWidth), KnownZero, KnownOne)) return &I; + } else if (isa(Op1)) { + return ReplaceInstUsesWith(I, Op0); // X ^ <0,0> -> X } if (ConstantInt *RHS = dyn_cast(Op1)) {