Canonicalize ladd constant to RHS.
authorRichard Osborne <richard@xmos.com>
Tue, 9 Mar 2010 16:13:57 +0000 (16:13 +0000)
committerRichard Osborne <richard@xmos.com>
Tue, 9 Mar 2010 16:13:57 +0000 (16:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98058 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/XCore/XCoreISelLowering.cpp

index e59b18cd2a30af68f392f9b489fb578aea5a11bc..d8cbd037cb2de4a175deeddce0dfddd63959bf72 100644 (file)
@@ -1105,6 +1105,10 @@ SDValue XCoreTargetLowering::PerformDAGCombine(SDNode *N,
     ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1);
     EVT VT = N0.getValueType();
 
+    // canonicalize constant to RHS
+    if (N0C && !N1C)
+      return DAG.getNode(XCoreISD::LADD, dl, DAG.getVTList(VT, VT), N1, N0, N2);
+
     // fold (ladd 0, 0, x) -> 0, x & 1
     if (N0C && N0C->isNullValue() && N1C && N1C->isNullValue()) {
       SDValue Carry = DAG.getConstant(0, VT);