Fix big-endian codegen bug. We're splitting up
authorDale Johannesen <dalej@apple.com>
Wed, 25 Feb 2009 22:39:13 +0000 (22:39 +0000)
committerDale Johannesen <dalej@apple.com>
Wed, 25 Feb 2009 22:39:13 +0000 (22:39 +0000)
overly long ints, e.g. i96, into pieces at PHIs
and the nodes that feed into them; however big-endian
reverses the order of the pieces (for some reason), and
wasn't doing it the same way on both sides, so
the pieces didn't match and runtime failures ensued.
Fixes 188.ammp and sqlite3 on ppc32.

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

lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp

index 91fecc322511d5bbe625332ed0ce995509c93a0e..3e8b753dcc6d1ea7fb7570b9c0f80da04e101e6f 100644 (file)
@@ -576,6 +576,7 @@ static void getCopyToParts(SelectionDAG &DAG, DebugLoc dl, SDValue Val,
   MVT PtrVT = TLI.getPointerTy();
   MVT ValueVT = Val.getValueType();
   unsigned PartBits = PartVT.getSizeInBits();
+  unsigned OrigNumParts = NumParts;
   assert(TLI.isTypeLegal(PartVT) && "Copying to an illegal type!");
 
   if (!NumParts)
@@ -673,7 +674,7 @@ static void getCopyToParts(SelectionDAG &DAG, DebugLoc dl, SDValue Val,
     }
 
     if (TLI.isBigEndian())
-      std::reverse(Parts, Parts + NumParts);
+      std::reverse(Parts, Parts + OrigNumParts);
 
     return;
   }