[PATCH] Fix wrong setcc result type when legalizing uaddo/usubo

Ke Bai ustcbike at gmail.com
Tue May 13 14:23:35 PDT 2014


There's no test because no other in tree targets change the bitwidth of the setcc type depending on the bitwidth of the compared type.

http://reviews.llvm.org/D3749

Files:
  LegalizeDAG.cpp

Index: LegalizeDAG.cpp
===================================================================
--- LegalizeDAG.cpp
+++ LegalizeDAG.cpp
@@ -3505,7 +3505,8 @@
                               ISD::ADD : ISD::SUB, dl, LHS.getValueType(),
                               LHS, RHS);
     Results.push_back(Sum);
-    EVT OType = Node->getValueType(1);
+    EVT ResultType = Node->getValueType(1);
+    EVT OType = getSetCCResultType(Node->getValueType(0));
 
     SDValue Zero = DAG.getConstant(0, LHS.getValueType());
 
@@ -3528,7 +3529,7 @@
     SDValue SumSignNE = DAG.getSetCC(dl, OType, LHSSign, SumSign, ISD::SETNE);
 
     SDValue Cmp = DAG.getNode(ISD::AND, dl, OType, SignsMatch, SumSignNE);
-    Results.push_back(Cmp);
+    Results.push_back(DAG.getBoolExtOrTrunc(Cmp, dl, ResultType));
     break;
   }
   case ISD::UADDO:
@@ -3539,9 +3540,14 @@
                               ISD::ADD : ISD::SUB, dl, LHS.getValueType(),
                               LHS, RHS);
     Results.push_back(Sum);
-    Results.push_back(DAG.getSetCC(dl, Node->getValueType(1), Sum, LHS,
-                                   Node->getOpcode () == ISD::UADDO ?
-                                   ISD::SETULT : ISD::SETUGT));
+
+    EVT ResultType = Node->getValueType(1);
+    EVT SetCCType = getSetCCResultType(Node->getValueType(0));
+    ISD::CondCode CC 
+      = Node->getOpcode() == ISD::UADDO ? ISD::SETULT : ISD::SETUGT;
+    SDValue SetCC = DAG.getSetCC(dl, SetCCType, Sum, LHS, CC);
+
+    Results.push_back(DAG.getBoolExtOrTrunc(SetCC, dl, ResultType));
     break;
   }
   case ISD::UMULO:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3749.9364.patch
Type: text/x-patch
Size: 1579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140513/278dd665/attachment.bin>


More information about the llvm-commits mailing list