diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2006-10-22 21:36:41 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2006-10-22 21:36:41 +0000 |
commit | 2c734f3fc16b437e00b51313fb960a4469734607 (patch) | |
tree | 01aca30672b5966c3d3eedabb24e0f2e2d0008b1 /llvm/lib/Transforms | |
parent | 76dd3bb34aaad51a11743cca9e7ec99982957524 (diff) | |
download | bcm5719-llvm-2c734f3fc16b437e00b51313fb960a4469734607.tar.gz bcm5719-llvm-2c734f3fc16b437e00b51313fb960a4469734607.zip |
Handle "if ((x|y) != 0)" for ints like we do for bools. Fixes missed
optimization opportunity pointed out by Chris Lattner.
llvm-svn: 31118
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp b/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp index 4d86f6aa46c..ca0d056e58c 100644 --- a/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -334,32 +334,35 @@ namespace { if (V1 == ConstantBool::getFalse()) add(Opcode, BO->getOperand(0), BO->getOperand(1), true); break; - case Instruction::And: - if (V1 == ConstantBool::getTrue()) { + case Instruction::And: { + ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V1); + if (CI && CI->isAllOnesValue()) { add(Opcode, V1, BO->getOperand(0), false); add(Opcode, V1, BO->getOperand(1), false); } - break; - case Instruction::Or: - if (V1 == ConstantBool::getFalse()) { + } break; + case Instruction::Or: { + ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V1); + if (CI && CI->isNullValue()) { add(Opcode, V1, BO->getOperand(0), false); add(Opcode, V1, BO->getOperand(1), false); } - break; - case Instruction::Xor: - if (V1 == ConstantBool::getTrue()) { + } break; + case Instruction::Xor: { + ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V1); + if (CI->isAllOnesValue()) { if (BO->getOperand(0) == V1) add(Opcode, ConstantBool::getFalse(), BO->getOperand(1), false); if (BO->getOperand(1) == V1) add(Opcode, ConstantBool::getFalse(), BO->getOperand(0), false); } - if (V1 == ConstantBool::getFalse()) { + if (CI->isNullValue()) { if (BO->getOperand(0) == ConstantBool::getTrue()) add(Opcode, ConstantBool::getTrue(), BO->getOperand(1), false); if (BO->getOperand(1) == ConstantBool::getTrue()) add(Opcode, ConstantBool::getTrue(), BO->getOperand(0), false); } - break; + } break; default: break; } |