Add a couple missing transforms in getSetCC that were triggering assertions
authorNate Begeman <natebegeman@mac.com>
Thu, 14 Apr 2005 08:56:52 +0000 (08:56 +0000)
committerNate Begeman <natebegeman@mac.com>
Thu, 14 Apr 2005 08:56:52 +0000 (08:56 +0000)
in the PPC Pattern ISel

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

lib/CodeGen/SelectionDAG/SelectionDAG.cpp

index 1926c2adb5b4482e6110dbdb2bf93bcbdcf24089..6790adb9d2c73046af719a7ac54d5a46406b6dfb 100644 (file)
@@ -436,11 +436,18 @@ SDOperand SelectionDAG::getSetCC(ISD::CondCode Cond, MVT::ValueType VT,
         N2C = cast<ConstantSDNode>(N2.Val);
       }
       
+      if ((Cond == ISD::SETLT || Cond == ISD::SETULT) && C2 == MinVal)
+        return getConstant(0, VT);      // X < MIN --> false
+        
+      // Canonicalize setgt X, Min --> setne X, Min
+      if ((Cond == ISD::SETGT || Cond == ISD::SETUGT) && C2 == MinVal)
+        return getSetCC(ISD::SETNE, VT, N1, N2);
+        
       // If we have setult X, 1, turn it into seteq X, 0
       if ((Cond == ISD::SETLT || Cond == ISD::SETULT) && C2 == MinVal+1)
         return getSetCC(ISD::SETEQ, VT, N1,
                         getConstant(MinVal, N1.getValueType()));
-      // If we have setult X, 1, turn it into seteq X, 0
+      // If we have setugt X, Max-1, turn it into seteq X, Max
       else if ((Cond == ISD::SETGT || Cond == ISD::SETUGT) && C2 == MaxVal-1)
         return getSetCC(ISD::SETEQ, VT, N1,
                         getConstant(MaxVal, N1.getValueType()));