aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2006-10-22 21:36:41 +0000
committerNick Lewycky <nicholas@mxc.ca>2006-10-22 21:36:41 +0000
commit5062250f361999975c6f1ff306dc3a365dc32e1b (patch)
treef93c45f5386285e2d701857036e081ccc3584998 /lib/Transforms/Scalar/PredicateSimplifier.cpp
parent96f5362ff29bb91baf48caed92637c7bb2ffd8d1 (diff)
Handle "if ((x|y) != 0)" for ints like we do for bools. Fixes missed
optimization opportunity pointed out by Chris Lattner. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31118 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/PredicateSimplifier.cpp')
-rw-r--r--lib/Transforms/Scalar/PredicateSimplifier.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp
index 4d86f6aa46..ca0d056e58 100644
--- a/lib/Transforms/Scalar/PredicateSimplifier.cpp
+++ b/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;
}