summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2006-09-20 23:02:24 +0000
committerNick Lewycky <nicholas@mxc.ca>2006-09-20 23:02:24 +0000
commitd74c55f483bf66560d0ae0d83c295cbb29a35b44 (patch)
tree5525361fbb706a29c3174c8e7f5c1efa4ac7a433 /llvm/lib/Transforms
parent3c5b3df6a07bba844943abf3f8054c5b89a41f9d (diff)
downloadbcm5719-llvm-d74c55f483bf66560d0ae0d83c295cbb29a35b44.tar.gz
bcm5719-llvm-d74c55f483bf66560d0ae0d83c295cbb29a35b44.zip
Once we're down to "setcc type constant1, constant2", at least come up
with the right answer. llvm-svn: 30550
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp b/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
index 8dc1a4d7d09..f57c0d94d20 100644
--- a/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
+++ b/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
@@ -524,6 +524,9 @@ Value *PredicateSimplifier::resolve(SetCondInst *SCI,
const PropertySet &KP) {
// Attempt to resolve the SetCondInst to a boolean.
+ static ConstantBool *True = ConstantBool::True,
+ *False = ConstantBool::False;
+
Value *SCI0 = resolve(SCI->getOperand(0), KP),
*SCI1 = resolve(SCI->getOperand(1), KP);
@@ -536,10 +539,8 @@ Value *PredicateSimplifier::resolve(SetCondInst *SCI,
if (NE != KP.Properties.end()) {
switch (SCI->getOpcode()) {
- case Instruction::SetEQ:
- return ConstantBool::False;
- case Instruction::SetNE:
- return ConstantBool::True;
+ case Instruction::SetEQ: return False;
+ case Instruction::SetNE: return True;
case Instruction::SetLE:
case Instruction::SetGE:
case Instruction::SetLT:
@@ -553,25 +554,20 @@ Value *PredicateSimplifier::resolve(SetCondInst *SCI,
return SCI;
}
+ uint64_t I1 = CI1->getRawValue(), I2 = CI2->getRawValue();
switch(SCI->getOpcode()) {
- case Instruction::SetLE:
- case Instruction::SetGE:
- case Instruction::SetEQ:
- if (CI1->getRawValue() == CI2->getRawValue())
- return ConstantBool::True;
- else
- return ConstantBool::False;
- case Instruction::SetLT:
- case Instruction::SetGT:
- case Instruction::SetNE:
- if (CI1->getRawValue() == CI2->getRawValue())
- return ConstantBool::False;
- else
- return ConstantBool::True;
+ case Instruction::SetLE: if (I1 <= I2) return True; else return False;
+ case Instruction::SetGE: if (I1 >= I2) return True; else return False;
+ case Instruction::SetEQ: if (I1 == I2) return True; else return False;
+ case Instruction::SetLT: if (I1 < I2) return True; else return False;
+ case Instruction::SetGT: if (I1 > I2) return True; else return False;
+ case Instruction::SetNE: if (I1 != I2) return True; else return False;
default:
assert(0 && "Unknown opcode in SetContInst.");
break;
}
+
+ return SCI;
}
Value *PredicateSimplifier::resolve(BinaryOperator *BO,
OpenPOWER on IntegriCloud