diff options
author | Chris Lattner <sabre@nondot.org> | 2005-10-09 22:08:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-10-09 22:08:50 +0000 |
commit | 5fb0deb43a3d59a5b2cdee2a51b20ee84babe607 (patch) | |
tree | 4312311bcee06c221e08e853bdb855535fd79137 /lib | |
parent | fa08fb2c782bb8c79b8b1503996d1193a772fcdb (diff) |
Make MaskedValueIsZero a bit more aggressive
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23677 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 7f74db50ca..cf4af79169 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -404,11 +404,17 @@ static bool MaskedValueIsZero(Value *V, ConstantIntegral *Mask) { switch (I->getOpcode()) { case Instruction::And: // (X & C1) & C2 == 0 iff C1 & C2 == 0. - if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(I->getOperand(1))) - if (ConstantExpr::getAnd(CI, Mask)->isNullValue()) + if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(I->getOperand(1))) { + ConstantIntegral *C1C2 = + cast<ConstantIntegral>(ConstantExpr::getAnd(CI, Mask)); + if (MaskedValueIsZero(I->getOperand(0), C1C2)) return true; - break; + } + // If either the LHS or the RHS are MaskedValueIsZero, the result is zero. + return MaskedValueIsZero(I->getOperand(1), Mask) || + MaskedValueIsZero(I->getOperand(0), Mask); case Instruction::Or: + case Instruction::Xor: // If the LHS and the RHS are MaskedValueIsZero, the result is also zero. return MaskedValueIsZero(I->getOperand(1), Mask) && MaskedValueIsZero(I->getOperand(0), Mask); |