diff options
author | Chris Lattner <sabre@nondot.org> | 2003-09-19 19:05:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-09-19 19:05:02 +0000 |
commit | 2da29177babb5c3b5fe6925ad6d42ec8c50e1501 (patch) | |
tree | d37b2c21e93ee7415ac90eb340b9fab1027b877f /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | d441d407cf6342f375f12133c9c747f36ee1924f (diff) | |
download | bcm5719-llvm-2da29177babb5c3b5fe6925ad6d42ec8c50e1501.tar.gz bcm5719-llvm-2da29177babb5c3b5fe6925ad6d42ec8c50e1501.zip |
Implement InstCombine/and.ll:test(15|16)
llvm-svn: 8607
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index daa943ca1e4..787c1a5caab 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -798,6 +798,33 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, } } break; + + case Instruction::Shl: { + // We know that the AND will not produce any of the bits shifted in, so if + // the anded constant includes them, clear them now! + // + Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType()); + Constant *CI = *AndRHS & *(*AllOne << *OpRHS); + if (CI != AndRHS) { + TheAnd.setOperand(1, CI); + return &TheAnd; + } + break; + } + case Instruction::Shr: + // We know that the AND will not produce any of the bits shifted in, so if + // the anded constant includes them, clear them now! This only applies to + // unsigned shifts, because a signed shr may bring in set bits! + // + if (AndRHS->getType()->isUnsigned()) { + Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType()); + Constant *CI = *AndRHS & *(*AllOne >> *OpRHS); + if (CI != AndRHS) { + TheAnd.setOperand(1, CI); + return &TheAnd; + } + } + break; } return 0; } |