Fix Regression/CodeGen/Generic/2006-04-26-SetCCAnd.ll and
PR748.

llvm-svn: 27987
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index c26632a..4809db4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -232,7 +232,22 @@
     return ISD::SETCC_INVALID;
 
   // Combine all of the condition bits.
-  return ISD::CondCode(Op1 & Op2);
+  ISD::CondCode Result = ISD::CondCode(Op1 & Op2);
+  
+  // Canonicalize illegal integer setcc's.
+  if (isInteger) {
+    switch (Result) {
+    default: break;
+    case ISD::SETUO:   // e.g. SETUGT & SETULT
+      Result = ISD::SETFALSE;
+      break;
+    case ISD::SETUEQ:  // e.g. SETUGE & SETULE
+      Result = ISD::SETEQ;
+      break;
+    }
+  }
+  
+  return Result;
 }
 
 const TargetMachine &SelectionDAG::getTarget() const {
@@ -849,6 +864,19 @@
   case ISD::SETFALSE2: return getConstant(0, VT);
   case ISD::SETTRUE:
   case ISD::SETTRUE2:  return getConstant(1, VT);
+    
+  case ISD::SETOEQ:
+  case ISD::SETOGT:
+  case ISD::SETOGE:
+  case ISD::SETOLT:
+  case ISD::SETOLE:
+  case ISD::SETONE:
+  case ISD::SETO:
+  case ISD::SETUO:
+  case ISD::SETUEQ:
+  case ISD::SETUNE:
+    assert(!MVT::isInteger(N1.getValueType()) && "Illegal setcc for integer!");
+    break;
   }
 
   if (ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N2.Val)) {