Check a comparion's operand type for legality before
authorDan Gohman <gohman@apple.com>
Fri, 5 Sep 2008 01:33:56 +0000 (01:33 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 5 Sep 2008 01:33:56 +0000 (01:33 +0000)
expanding its operands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55820 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86FastISel.cpp

index 1314f636826c24e123984309cdf8a16bd769912c..6f6b9908da196a5b148a6f9cf6c0d2c655504234 100644 (file)
@@ -262,15 +262,15 @@ bool X86FastISel::X86SelectLoad(Instruction *I)  {
 bool X86FastISel::X86SelectCmp(Instruction *I) {
   CmpInst *CI = cast<CmpInst>(I);
 
+  MVT VT = TLI.getValueType(I->getOperand(0)->getType());
+  if (!TLI.isTypeLegal(VT))
+    return false;
+
   unsigned Op0Reg = getRegForValue(CI->getOperand(0));
   if (Op0Reg == 0) return false;
   unsigned Op1Reg = getRegForValue(CI->getOperand(1));
   if (Op1Reg == 0) return false;
 
-  MVT VT = TLI.getValueType(I->getOperand(0)->getType());
-  if (!TLI.isTypeLegal(VT))
-    return false;
-
   unsigned Opc;
   switch (VT.getSimpleVT()) {
   case MVT::i8: Opc = X86::CMP8rr; break;