diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-10-17 04:01:51 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-10-17 04:01:51 +0000 |
| commit | 192eaccc1aaa810374e1fcafb3183decc51f5fd7 (patch) | |
| tree | 5c28d33b42175d3fc5a2a38f799c2f8fb5270a14 /llvm/lib | |
| parent | 0e4818c99a6bcfc91e02b21146534c13cbfdaa83 (diff) | |
| download | bcm5719-llvm-192eaccc1aaa810374e1fcafb3183decc51f5fd7.tar.gz bcm5719-llvm-192eaccc1aaa810374e1fcafb3183decc51f5fd7.zip | |
Fix constant folding relational operators with undef operands.
llvm-svn: 17077
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/ConstantFolding.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/llvm/lib/VMCore/ConstantFolding.cpp b/llvm/lib/VMCore/ConstantFolding.cpp index 2e8ed54ec64..b56366ea663 100644 --- a/llvm/lib/VMCore/ConstantFolding.cpp +++ b/llvm/lib/VMCore/ConstantFolding.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()); |

