summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/ConstantFolding.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-01 01:23:19 +0000
committerChris Lattner <sabre@nondot.org>2004-02-01 01:23:19 +0000
commit125ed54fdcb8143c39004127e0edc9a504d9fb17 (patch)
tree0310d483f67f95974c004db159cdc62fcb3107eb /llvm/lib/VMCore/ConstantFolding.cpp
parent93f7c408798b1f60c5b31d926b379baf08443ea3 (diff)
downloadbcm5719-llvm-125ed54fdcb8143c39004127e0edc9a504d9fb17.tar.gz
bcm5719-llvm-125ed54fdcb8143c39004127e0edc9a504d9fb17.zip
Fix a crasher bug in my constant folding rewrite
llvm-svn: 11044
Diffstat (limited to 'llvm/lib/VMCore/ConstantFolding.cpp')
-rw-r--r--llvm/lib/VMCore/ConstantFolding.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/ConstantFolding.cpp b/llvm/lib/VMCore/ConstantFolding.cpp
index 094ec373f10..28d671b898c 100644
--- a/llvm/lib/VMCore/ConstantFolding.cpp
+++ b/llvm/lib/VMCore/ConstantFolding.cpp
@@ -625,11 +625,18 @@ static Instruction::BinaryOps evaluateRelation(const Constant *V1,
// If the first operand is simple, swap operands.
assert((isa<ConstantPointerRef>(V2) || isa<ConstantExpr>(V2)) &&
"Simple cases should have been handled by caller!");
- return SetCondInst::getSwappedCondition(evaluateRelation(V2, V1));
+ Instruction::BinaryOps SwappedRelation = evaluateRelation(V2, V1);
+ if (SwappedRelation != Instruction::BinaryOpsEnd)
+ return SetCondInst::getSwappedCondition(SwappedRelation);
} else if (const ConstantPointerRef *CPR1 = dyn_cast<ConstantPointerRef>(V1)){
- if (isa<ConstantExpr>(V2)) // Swap as necessary.
- return SetCondInst::getSwappedCondition(evaluateRelation(V2, V1));
+ if (isa<ConstantExpr>(V2)) { // Swap as necessary.
+ Instruction::BinaryOps SwappedRelation = evaluateRelation(V2, V1);
+ if (SwappedRelation != Instruction::BinaryOpsEnd)
+ return SetCondInst::getSwappedCondition(SwappedRelation);
+ else
+ return Instruction::BinaryOpsEnd;
+ }
// Now we know that the RHS is a ConstantPointerRef or simple constant,
// which (since the types must match) means that it's a ConstantPointerNull.
OpenPOWER on IntegriCloud