Fix an altivec constant miscompilation that Duncan found through
authorChris Lattner <sabre@nondot.org>
Thu, 10 Jul 2008 16:33:38 +0000 (16:33 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 10 Jul 2008 16:33:38 +0000 (16:33 +0000)
his work on legalizetypes.

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

lib/Target/PowerPC/PPCISelLowering.cpp
test/CodeGen/PowerPC/2008-07-10-SplatMiscompile.ll [new file with mode: 0644]

index 4650ad720ca03336f670310d3a581a474977c7d1..4225ada887f6897657ce0094326a94768071f301 100644 (file)
@@ -3399,8 +3399,10 @@ SDOperand PPCTargetLowering::LowerBUILD_VECTOR(SDOperand Op,
     // If this value is in the range [-32,30] and is even, use:
     //    tmp = VSPLTI[bhw], result = add tmp, tmp
     if (SextVal >= -32 && SextVal <= 30 && (SextVal & 1) == 0) {
-      Op = BuildSplatI(SextVal >> 1, SplatSize, Op.getValueType(), DAG);
-      return DAG.getNode(ISD::ADD, Op.getValueType(), Op, Op);
+      SDOperand Res = BuildSplatI(SextVal >> 1, SplatSize, MVT::Other, DAG);
+      Res = DAG.getNode(ISD::ADD, Res.getValueType(), Res, Res);
+      return DAG.getNode(ISD::BIT_CONVERT, Op.getValueType(), Res);
+
     }
     
     // If this is 0x8000_0000 x 4, turn into vspltisw + vslw.  If it is 
diff --git a/test/CodeGen/PowerPC/2008-07-10-SplatMiscompile.ll b/test/CodeGen/PowerPC/2008-07-10-SplatMiscompile.ll
new file mode 100644 (file)
index 0000000..b6b9c89
--- /dev/null
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | llc -march=ppc32 -mcpu=g5 | grep vadduhm
+; RUN: llvm-as < %s | llc -march=ppc32 -mcpu=g5 | grep vsubuhm
+
+define <4 x i32> @test() nounwind {
+       ret <4 x i32> < i32 4293066722, i32 4293066722, i32 4293066722, i32 4293066722>
+}
+
+define <4 x i32> @test2() nounwind {
+       ret <4 x i32> < i32 1114129, i32 1114129, i32 1114129, i32 1114129>
+}