[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Oct 16 21:02:04 PDT 2004



Changes in directory llvm/lib/VMCore:

ConstantFolding.cpp updated: 1.65 -> 1.66
---
Log message:

Fix constant folding relational operators with undef operands.


---
Diffs of the changes:  (+4 -7)

Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.65 llvm/lib/VMCore/ConstantFolding.cpp:1.66
--- llvm/lib/VMCore/ConstantFolding.cpp:1.65	Sat Oct 16 18:31:32 2004
+++ llvm/lib/VMCore/ConstantFolding.cpp	Sat Oct 16 23:01:51 2004
@@ -830,7 +830,9 @@
   // 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 @@
       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());
 






More information about the llvm-commits mailing list