From 84fef1f55d6be054fa8a42c1561bcc97d0dd0f11 Mon Sep 17 00:00:00 2001 From: Bill Schmidt Date: Mon, 4 Aug 2014 23:21:01 +0000 Subject: [PATCH] [PPC64LE] Fix wrong IR for vec_sld and vec_vsldoi My original LE implementation of the vsldoi instruction, with its altivec.h interfaces vec_sld and vec_vsldoi, produces incorrect shufflevector operations in the LLVM IR. Correct code is generated because the back end handles the incorrect shufflevector in a consistent manner. This patch and a companion patch for Clang correct this problem by removing the fixup from altivec.h and the corresponding fixup from the PowerPC back end. Several test cases are also modified to reflect the now-correct LLVM IR. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214800 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/PPCISelLowering.cpp | 42 ++++++++------------------ test/CodeGen/PowerPC/vec_shuffle_le.ll | 4 +-- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp index 4028fedb6c5..8ddfd776726 100644 --- a/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/lib/Target/PowerPC/PPCISelLowering.cpp @@ -1009,38 +1009,20 @@ int PPC::isVSLDOIShuffleMask(SDNode *N, bool isUnary, SelectionDAG &DAG) { unsigned ShiftAmt = SVOp->getMaskElt(i); if (ShiftAmt < i) return -1; - if (DAG.getTarget().getSubtargetImpl()->getDataLayout()->isLittleEndian()) { - - ShiftAmt += i; - - if (!isUnary) { - // Check the rest of the elements to see if they are consecutive. - for (++i; i != 16; ++i) - if (!isConstantOrUndef(SVOp->getMaskElt(i), ShiftAmt - i)) - return -1; - } else { - // Check the rest of the elements to see if they are consecutive. - for (++i; i != 16; ++i) - if (!isConstantOrUndef(SVOp->getMaskElt(i), (ShiftAmt - i) & 15)) - return -1; - } - - } else { // Big Endian + ShiftAmt -= i; - ShiftAmt -= i; - - if (!isUnary) { - // Check the rest of the elements to see if they are consecutive. - for (++i; i != 16; ++i) - if (!isConstantOrUndef(SVOp->getMaskElt(i), ShiftAmt+i)) - return -1; - } else { - // Check the rest of the elements to see if they are consecutive. - for (++i; i != 16; ++i) - if (!isConstantOrUndef(SVOp->getMaskElt(i), (ShiftAmt+i) & 15)) - return -1; - } + if (!isUnary) { + // Check the rest of the elements to see if they are consecutive. + for (++i; i != 16; ++i) + if (!isConstantOrUndef(SVOp->getMaskElt(i), ShiftAmt+i)) + return -1; + } else { + // Check the rest of the elements to see if they are consecutive. + for (++i; i != 16; ++i) + if (!isConstantOrUndef(SVOp->getMaskElt(i), (ShiftAmt+i) & 15)) + return -1; } + return ShiftAmt; } diff --git a/test/CodeGen/PowerPC/vec_shuffle_le.ll b/test/CodeGen/PowerPC/vec_shuffle_le.ll index 4fd41a7830d..efebece09f4 100644 --- a/test/CodeGen/PowerPC/vec_shuffle_le.ll +++ b/test/CodeGen/PowerPC/vec_shuffle_le.ll @@ -189,7 +189,7 @@ entry: ; CHECK: VSLDOI_xy: %tmp = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B - %tmp3 = shufflevector <16 x i8> %tmp, <16 x i8> %tmp2, <16 x i32> + %tmp3 = shufflevector <16 x i8> %tmp, <16 x i8> %tmp2, <16 x i32> ; CHECK: vsldoi store <16 x i8> %tmp3, <16 x i8>* %A ret void @@ -199,7 +199,7 @@ define void @VSLDOI_xx(<16 x i8>* %A) { entry: ; CHECK: VSLDOI_xx: %tmp = load <16 x i8>* %A - %tmp2 = shufflevector <16 x i8> %tmp, <16 x i8> %tmp, <16 x i32> + %tmp2 = shufflevector <16 x i8> %tmp, <16 x i8> %tmp, <16 x i32> ; CHECK: vsldoi store <16 x i8> %tmp2, <16 x i8>* %A ret void -- 2.34.1