[x86] Assert on invalid immediates in the instruction printer for cmp.ps/pd/ss/sd...
[oota-llvm.git] / lib / Target / X86 / InstPrinter / X86IntelInstPrinter.cpp
index f5fd9845d9099031ebcbb289b450e3c0621bcf8a..449445df7d27cd944bb16f95d5dd1fd1a2e7dc56 100644 (file)
@@ -90,13 +90,15 @@ static void printSSEAVXCC(int64_t Imm, raw_ostream &O) {
 
 void X86IntelInstPrinter::printSSECC(const MCInst *MI, unsigned Op,
                                      raw_ostream &O) {
-  int64_t Imm = MI->getOperand(Op).getImm() & 0x7;
+  int64_t Imm = MI->getOperand(Op).getImm();
+  assert((Imm & 0x7) == Imm); // Ensure valid immediate.
   printSSEAVXCC(Imm, O);
 }
 
 void X86IntelInstPrinter::printAVXCC(const MCInst *MI, unsigned Op,
                                      raw_ostream &O) {
-  int64_t Imm = MI->getOperand(Op).getImm() & 0x1f;
+  int64_t Imm = MI->getOperand(Op).getImm();
+  assert((Imm & 0x1f) == Imm); // Ensure valid immediate.
   printSSEAVXCC(Imm, O);
 }