Fix minor issues with VICmp/VFCmp constant expressions
authorNate Begeman <natebegeman@mac.com>
Fri, 25 Jul 2008 17:35:37 +0000 (17:35 +0000)
committerNate Begeman <natebegeman@mac.com>
Fri, 25 Jul 2008 17:35:37 +0000 (17:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54030 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h
lib/Analysis/ConstantFolding.cpp
lib/VMCore/Constants.cpp

index 5d85ee23e7ca411e60f7d8c97a89798994cf4b74..d91dfca9f88a74477ba0bebdbc79b28d0b61d420 100644 (file)
@@ -565,7 +565,7 @@ protected:
   static Constant *getTy(const Type *Ty, unsigned Opcode,
                          Constant *C1, Constant *C2);
   static Constant *getCompareTy(unsigned short pred, Constant *C1, 
-                                Constant *C2);
+                                Constant *C2, bool isVecCmp = false);
   static Constant *getSelectTy(const Type *Ty,
                                Constant *C1, Constant *C2, Constant *C3);
   static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,
@@ -677,7 +677,8 @@ public:
   ///
   static Constant *get(unsigned Opcode, Constant *C1, Constant *C2);
 
-  /// @brief Return an ICmp or FCmp comparison operator constant expression.
+  /// @brief Return an ICmp, FCmp, VICmp, or VFCmp comparison operator constant
+  /// expression.
   static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2);
 
   /// ConstantExpr::get* - Return some common constants without having to
index 43597c85f16237ad35b4229c584eacd0d1b3ce3d..1a0e4b410c3a201dfbf0633e2b0de0b7272c70fc 100644 (file)
@@ -358,6 +358,8 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
     return 0;
   case Instruction::ICmp:
   case Instruction::FCmp:
+  case Instruction::VICmp:
+  case Instruction::VFCmp:
     assert(0 &&"This function is invalid for compares: no predicate specified");
   case Instruction::PtrToInt:
     // If the input is a inttoptr, eliminate the pair.  This requires knowing
@@ -473,7 +475,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate,
       }
     }
   }
-  return ConstantExpr::getCompare(Predicate, Ops[0], Ops[1]); 
+  return ConstantExpr::getCompare(Predicate, Ops[0], Ops[1]);
 }
 
 
index e22449bab63683319b274ba52621df7f27f7b814..48034703c884eb3eb5a53c1112bd9d0d00e4bb12 100644 (file)
@@ -2003,21 +2003,24 @@ Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
 }
 
 Constant *ConstantExpr::getCompareTy(unsigned short predicate,
-                                     Constant *C1, Constant *C2) {
+                                     Constant *C1, Constant *C2,
+                                     bool isVecCmp) {
   switch (predicate) {
     default: assert(0 && "Invalid CmpInst predicate");
-    case FCmpInst::FCMP_FALSE: case FCmpInst::FCMP_OEQ: case FCmpInst::FCMP_OGT:
-    case FCmpInst::FCMP_OGE: case FCmpInst::FCMP_OLT: case FCmpInst::FCMP_OLE:
-    case FCmpInst::FCMP_ONE: case FCmpInst::FCMP_ORD: case FCmpInst::FCMP_UNO:
-    case FCmpInst::FCMP_UEQ: case FCmpInst::FCMP_UGT: case FCmpInst::FCMP_UGE:
-    case FCmpInst::FCMP_ULT: case FCmpInst::FCMP_ULE: case FCmpInst::FCMP_UNE:
-    case FCmpInst::FCMP_TRUE:
-      return getFCmp(predicate, C1, C2);
-    case ICmpInst::ICMP_EQ: case ICmpInst::ICMP_NE: case ICmpInst::ICMP_UGT:
-    case ICmpInst::ICMP_UGE: case ICmpInst::ICMP_ULT: case ICmpInst::ICMP_ULE:
-    case ICmpInst::ICMP_SGT: case ICmpInst::ICMP_SGE: case ICmpInst::ICMP_SLT:
-    case ICmpInst::ICMP_SLE:
-      return getICmp(predicate, C1, C2);
+    case CmpInst::FCMP_FALSE: case CmpInst::FCMP_OEQ: case CmpInst::FCMP_OGT:
+    case CmpInst::FCMP_OGE:   case CmpInst::FCMP_OLT: case CmpInst::FCMP_OLE:
+    case CmpInst::FCMP_ONE:   case CmpInst::FCMP_ORD: case CmpInst::FCMP_UNO:
+    case CmpInst::FCMP_UEQ:   case CmpInst::FCMP_UGT: case CmpInst::FCMP_UGE:
+    case CmpInst::FCMP_ULT:   case CmpInst::FCMP_ULE: case CmpInst::FCMP_UNE:
+    case CmpInst::FCMP_TRUE:
+      return isVecCmp ? getVFCmp(predicate, C1, C2) 
+                      : getFCmp(predicate, C1, C2);
+    case CmpInst::ICMP_EQ:  case CmpInst::ICMP_NE:  case CmpInst::ICMP_UGT:
+    case CmpInst::ICMP_UGE: case CmpInst::ICMP_ULT: case CmpInst::ICMP_ULE:
+    case CmpInst::ICMP_SGT: case CmpInst::ICMP_SGE: case CmpInst::ICMP_SLT:
+    case CmpInst::ICMP_SLE:
+      return isVecCmp ? getVICmp(predicate, C1, C2)
+                      : getICmp(predicate, C1, C2);
   }
 }