[llvm] r213931 - [SDAG] Enable the new assert for out-of-range result numbers in

Chandler Carruth chandlerc at gmail.com
Fri Jul 25 02:19:23 PDT 2014


Author: chandlerc
Date: Fri Jul 25 04:19:23 2014
New Revision: 213931

URL: http://llvm.org/viewvc/llvm-project?rev=213931&view=rev
Log:
[SDAG] Enable the new assert for out-of-range result numbers in
SDValues, fixing the two bugs left in the regression suite.

The key for both of these was the use a single value type rather than
a VTList which caused an unintentionally single-result merge-value node.
Fix this by getting the appropriate VTList in place.

Doing this exposed that the comments in x86's code abouth how MUL_LOHI
operands are handle is wrong. The bug with the use of out-of-range
result numbers was hiding the bug about the order of operands here (as
best i can tell). There are more places where the code appears to get
this backwards still...

Modified:
    llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
    llvm/trunk/lib/Target/R600/AMDGPUISelLowering.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=213931&r1=213930&r2=213931&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Fri Jul 25 04:19:23 2014
@@ -885,13 +885,8 @@ public:
 
 inline SDValue::SDValue(SDNode *node, unsigned resno)
     : Node(node), ResNo(resno) {
-// This is currently disabled because it fires pretty widely, but I wanted to
-// commit it so others could help reproduce and aid in the cleanup. It will get
-// enabled ASAP.
-#if 0
   assert((!Node || ResNo < Node->getNumValues()) &&
          "Invalid result number for the given node!");
-#endif
   assert(ResNo < -2U && "Cannot use result numbers reserved for DenseMaps.");
 }
 

Modified: llvm/trunk/lib/Target/R600/AMDGPUISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUISelLowering.cpp?rev=213931&r1=213930&r2=213931&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/AMDGPUISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/R600/AMDGPUISelLowering.cpp Fri Jul 25 04:19:23 2014
@@ -823,8 +823,8 @@ SDValue AMDGPUTargetLowering::LowerINTRI
       SDValue Denominator = Op.getOperand(2);
       SDValue Src0 = Param->isAllOnesValue() ? Numerator : Denominator;
 
-      return DAG.getNode(AMDGPUISD::DIV_SCALE, DL, VT,
-                         Src0, Denominator, Numerator);
+      return DAG.getNode(AMDGPUISD::DIV_SCALE, DL, Op->getVTList(), Src0,
+                         Denominator, Numerator);
     }
 
     case Intrinsic::AMDGPU_div_fmas:

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=213931&r1=213930&r2=213931&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Jul 25 04:19:23 2014
@@ -15478,9 +15478,10 @@ static SDValue LowerMUL_LOHI(SDValue Op,
     Highs = DAG.getNode(ISD::SUB, dl, VT, Highs, Fixup);
   }
 
-  // The low part of a MUL_LOHI is supposed to be the first value and the
-  // high part the second value.
-  return DAG.getNode(ISD::MERGE_VALUES, dl, Op.getValueType(), Lows, Highs);
+  // THe first result of MUL_LOHI is actually the high value, followed by the
+  // low value.
+  SDValue Ops[] = {Highs, Lows};
+  return DAG.getMergeValues(Ops, dl);
 }
 
 static SDValue LowerScalarImmediateShift(SDValue Op, SelectionDAG &DAG,





More information about the llvm-commits mailing list