diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-05-06 04:53:20 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-05-06 04:53:20 +0000 |
| commit | ef298a3b8a1a8b0d9a0165fe5ed430569d6e350f (patch) | |
| tree | 9310934625a896cc8b18ec2ecee0f7e87541975d /llvm/lib/Transforms | |
| parent | 8d83be2bf0349056cebf0dfa7f01de1756939ecb (diff) | |
| download | bcm5719-llvm-ef298a3b8a1a8b0d9a0165fe5ed430569d6e350f.tar.gz bcm5719-llvm-ef298a3b8a1a8b0d9a0165fe5ed430569d6e350f.zip | |
Teach instcombine propagate zeroness through shl instructions, implementing
and.ll:test31
llvm-svn: 21717
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 6cc7bbe3dc7..51141162bfb 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1361,14 +1361,10 @@ static bool MaskedValueIsZero(Value *V, ConstantIntegral *Mask) { break; } case Instruction::Shl: - // (shl X, C1) & C2 == 0 iff (-1 << C1) & C2 == 0 - if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) { - Constant *C1 = ConstantIntegral::getAllOnesValue(I->getType()); - C1 = ConstantExpr::getShl(C1, SA); - C1 = ConstantExpr::getAnd(C1, Mask); - if (C1->isNullValue()) - return true; - } + // (shl X, C1) & C2 == 0 iff (X & C2 >>u C1) == 0 + if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) + return MaskedValueIsZero(I->getOperand(0), + cast<ConstantIntegral>(ConstantExpr::getUShr(Mask, SA))); break; case Instruction::Shr: // (ushr X, C1) & C2 == 0 iff (-1 >> C1) & C2 == 0 |

