summaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-10-17 04:01:51 +0000
committerChris Lattner <sabre@nondot.org>2004-10-17 04:01:51 +0000
commit35f92ae3af08e79f60c6d09b38f650a29b1c2cbf (patch)
tree69716cdc99caa24af79e8168fba8755583aec238 /lib/VMCore
parenta78a9027f5300f29155cd5614b933142fb0f7397 (diff)
downloadexternal_llvm-35f92ae3af08e79f60c6d09b38f650a29b1c2cbf.zip
external_llvm-35f92ae3af08e79f60c6d09b38f650a29b1c2cbf.tar.gz
external_llvm-35f92ae3af08e79f60c6d09b38f650a29b1c2cbf.tar.bz2
Fix constant folding relational operators with undef operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/ConstantFold.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 2e8ed54..b56366e 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -830,7 +830,9 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
// If we successfully folded the expression, return it now.
if (C) return C;
- if (SetCondInst::isRelational(Opcode))
+ if (SetCondInst::isRelational(Opcode)) {
+ if (isa<UndefValue>(V1) || isa<UndefValue>(V2))
+ return UndefValue::get(Type::BoolTy);
switch (evaluateRelation(V1, V2)) {
default: assert(0 && "Unknown relational!");
case Instruction::BinaryOpsEnd:
@@ -871,17 +873,12 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
if (Opcode == Instruction::SetNE) return ConstantBool::True;
break;
}
+ }
if (isa<UndefValue>(V1) || isa<UndefValue>(V2)) {
switch (Opcode) {
case Instruction::Add:
case Instruction::Sub:
- case Instruction::SetEQ:
- case Instruction::SetNE:
- case Instruction::SetLT:
- case Instruction::SetLE:
- case Instruction::SetGT:
- case Instruction::SetGE:
case Instruction::Xor:
return UndefValue::get(V1->getType());