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

Chris Lattner lattner at cs.uiuc.edu
Wed Aug 4 11:50:19 PDT 2004



Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.99 -> 1.100
---
Log message:

Fix a latent bug exposed by my recent changes


---
Diffs of the changes:  (+9 -1)

Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.99 llvm/lib/VMCore/Constants.cpp:1.100
--- llvm/lib/VMCore/Constants.cpp:1.99	Wed Aug  4 03:02:59 2004
+++ llvm/lib/VMCore/Constants.cpp	Wed Aug  4 13:50:09 2004
@@ -1109,7 +1109,8 @@
   assert(C1->getType() == C2->getType() &&
          "Operand types in binary constant expression should match");
 
-  if (ReqTy == C1->getType())
+  if (ReqTy == C1->getType() || (Instruction::isRelational(Opcode) &&
+                                 ReqTy == Type::BoolTy))
     if (Constant *FC = ConstantFoldBinaryInstruction(Opcode, C1, C2))
       return FC;          // Fold a few common cases...
 
@@ -1118,6 +1119,13 @@
   return ExprConstants.getOrCreate(ReqTy, Key);
 }
 
+Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
+  if (Instruction::isRelational(Opcode))
+    return getTy(Type::BoolTy, Opcode, C1, C2);
+  else
+    return getTy(C1->getType(), Opcode, C1, C2);
+}
+
 Constant *ConstantExpr::getSelectTy(const Type *ReqTy, Constant *C,
                                     Constant *V1, Constant *V2) {
   assert(C->getType() == Type::BoolTy && "Select condition must be bool!");






More information about the llvm-commits mailing list