Use parameter attribute store (soon to be renamed) for
[oota-llvm.git] / lib / Bitcode / Writer / BitcodeWriter.cpp
index dd161bacfb32a5c63c0c97a9c4f726259e74612b..931e944a410d1dc13f9abe128a4b5b95771cfb2f 100644 (file)
@@ -640,7 +640,14 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
       case Instruction::FCmp:
       case Instruction::VICmp:
       case Instruction::VFCmp:
-        Code = bitc::CST_CODE_CE_CMP;
+        if (isa<VectorType>(C->getOperand(0)->getType())
+            && (CE->getOpcode() == Instruction::ICmp
+                || CE->getOpcode() == Instruction::FCmp)) {
+          // compare returning vector of Int1Ty
+          assert(0 && "Unsupported constant!");
+        } else {
+          Code = bitc::CST_CODE_CE_CMP;
+        }
         Record.push_back(VE.getTypeID(C->getOperand(0)->getType()));
         Record.push_back(VE.getValueID(C->getOperand(0)));
         Record.push_back(VE.getValueID(C->getOperand(1)));
@@ -738,10 +745,10 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
     break;
   }
   case Instruction::Select:
-    Code = bitc::FUNC_CODE_INST_SELECT;
+    Code = bitc::FUNC_CODE_INST_VSELECT;
     PushValueAndType(I.getOperand(1), InstID, Vals, VE);
     Vals.push_back(VE.getValueID(I.getOperand(2)));
-    Vals.push_back(VE.getValueID(I.getOperand(0)));
+    PushValueAndType(I.getOperand(0), InstID, Vals, VE);
     break;
   case Instruction::ExtractElement:
     Code = bitc::FUNC_CODE_INST_EXTRACTELT;
@@ -764,7 +771,13 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
   case Instruction::FCmp:
   case Instruction::VICmp:
   case Instruction::VFCmp:
-    Code = bitc::FUNC_CODE_INST_CMP;
+    if (I.getOpcode() == Instruction::ICmp
+        || I.getOpcode() == Instruction::FCmp) {
+      // compare returning Int1Ty or vector of Int1Ty
+      Code = bitc::FUNC_CODE_INST_CMP2;
+    } else {
+      Code = bitc::FUNC_CODE_INST_CMP;
+    }
     PushValueAndType(I.getOperand(0), InstID, Vals, VE);
     Vals.push_back(VE.getValueID(I.getOperand(1)));
     Vals.push_back(cast<CmpInst>(I).getPredicate());