aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2007-01-12 00:02:12 +0000
committerNick Lewycky <nicholas@mxc.ca>2007-01-12 00:02:12 +0000
commitc2a7d097f940f5265a8a56f98103030984dfa769 (patch)
tree6e107947eff2ae7f14754157e461c8cbce463f22 /lib/Transforms/Scalar/PredicateSimplifier.cpp
parent36bcb82c3f7acd7cc3a79f51102c5995db2fb723 (diff)
Clean up logic after ConstantBool removal.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33096 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/PredicateSimplifier.cpp')
-rw-r--r--lib/Transforms/Scalar/PredicateSimplifier.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp
index c577409f9a..8defb871b7 100644
--- a/lib/Transforms/Scalar/PredicateSimplifier.cpp
+++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp
@@ -432,11 +432,8 @@ namespace {
NodeMap.insert(std::lower_bound(NodeMap.begin(), NodeMap.end(),
MapEntry), MapEntry);
-#if 1
- // This is the missing piece to turn on VRP.
if (Constant *C = dyn_cast<Constant>(V))
initializeConstant(C, MapEntry.index);
-#endif
return MapEntry.index;
}
@@ -1127,14 +1124,12 @@ namespace {
Value *RHS = Op1;
if (!isa<Constant>(LHS)) std::swap(LHS, RHS);
- ConstantInt *CB, *A;
- if ((CB = dyn_cast<ConstantInt>(Canonical)) &&
- CB->getType() == Type::Int1Ty) {
- if ((A = dyn_cast<ConstantInt>(LHS)) &&
- A->getType() == Type::Int1Ty)
- add(RHS, ConstantInt::get(A->getBoolValue() ^
- CB->getBoolValue()),
- ICmpInst::ICMP_EQ, NewContext);
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(Canonical)) {
+ if (ConstantInt *Arg = dyn_cast<ConstantInt>(LHS)) {
+ add(RHS, ConstantInt::get(CI->getType(), CI->getZExtValue() ^
+ Arg->getZExtValue()),
+ ICmpInst::ICMP_EQ, NewContext);
+ }
}
if (Canonical == LHS) {
if (isa<ConstantInt>(Canonical))
@@ -1238,21 +1233,18 @@ namespace {
case Instruction::Or:
case Instruction::Add:
case Instruction::Sub:
- add(Unknown, Constant::getNullValue(Ty), ICmpInst::ICMP_EQ, NewContext);
+ add(Unknown, Constant::getNullValue(Ty), ICmpInst::ICMP_EQ,
+ NewContext);
break;
case Instruction::UDiv:
case Instruction::SDiv:
if (Unknown == Op0) break; // otherwise, fallthrough
case Instruction::And:
case Instruction::Mul:
- Constant *One = NULL;
- if (isa<ConstantInt>(Unknown))
- One = ConstantInt::get(Ty, 1);
- else if (isa<ConstantInt>(Unknown) &&
- Unknown->getType() == Type::Int1Ty)
- One = ConstantInt::getTrue();
-
- if (One) add(Unknown, One, ICmpInst::ICMP_EQ, NewContext);
+ if (isa<ConstantInt>(Unknown)) {
+ Constant *One = ConstantInt::get(Ty, 1);
+ add(Unknown, One, ICmpInst::ICMP_EQ, NewContext);
+ }
break;
}
}
@@ -1274,6 +1266,8 @@ namespace {
add(IC, ConstantInt::getFalse(), ICmpInst::ICMP_EQ, NewContext);
}
+ // TODO: "bool %x s<u> %y" implies %x = true and %y = false.
+
// TODO: make the predicate more strict, if possible.
} else if (SelectInst *SI = dyn_cast<SelectInst>(I)) {