[llvm-commits] CVS: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
Nick Lewycky
nicholas at mxc.ca
Sun Oct 22 14:36:58 PDT 2006
Changes in directory llvm/lib/Transforms/Scalar:
PredicateSimplifier.cpp updated: 1.21 -> 1.22
---
Log message:
Handle "if ((x|y) != 0)" for ints like we do for bools. Fixes missed
optimization opportunity pointed out by Chris Lattner.
---
Diffs of the changes: (+13 -10)
PredicateSimplifier.cpp | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.21 llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.22
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.21 Sun Oct 22 14:53:27 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp Sun Oct 22 16:36:41 2006
@@ -334,32 +334,35 @@
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;
}
More information about the llvm-commits
mailing list