llvm.org GIT mirror llvm / b777868
Merging r214718: ------------------------------------------------------------------------ r214718 | uweigand | 2014-08-04 08:53:40 -0500 (Mon, 04 Aug 2014) | 12 lines [PowerPC] Swap arguments to vpkuhum/vpkuwum on little-endian In commit r213915, Bill fixed little-endian usage of vmrgh* and vmrgl* by swapping the input arguments. As it turns out, the exact same fix is also required for the vpkuhum/vpkuwum patterns. This fixes another regression in llvmpipe when vector support is enabled. Reviewed by Bill Schmidt. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_35@214819 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Schmidt 5 years ago
4 changed file(s) with 76 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
851851
852852 /// isVPKUHUMShuffleMask - Return true if this is the shuffle mask for a
853853 /// VPKUHUM instruction.
854 bool PPC::isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, bool isUnary,
854 /// The ShuffleKind distinguishes between big-endian operations with
855 /// two different inputs (0), either-endian operations with two identical
856 /// inputs (1), and little-endian operantion with two different inputs (2).
857 /// For the latter, the input operands are swapped (see PPCInstrAltivec.td).
858 bool PPC::isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
855859 SelectionDAG &DAG) {
856 unsigned j = DAG.getTarget().getDataLayout()->isLittleEndian() ? 0 : 1;
857 if (!isUnary) {
860 if (ShuffleKind == 0) {
861 if (DAG.getTarget().getDataLayout()->isLittleEndian())
862 return false;
858863 for (unsigned i = 0; i != 16; ++i)
859 if (!isConstantOrUndef(N->getMaskElt(i), i*2+j))
864 if (!isConstantOrUndef(N->getMaskElt(i), i*2+1))
860865 return false;
861 } else {
866 } else if (ShuffleKind == 2) {
867 if (!DAG.getTarget().getDataLayout()->isLittleEndian())
868 return false;
869 for (unsigned i = 0; i != 16; ++i)
870 if (!isConstantOrUndef(N->getMaskElt(i), i*2))
871 return false;
872 } else if (ShuffleKind == 1) {
873 unsigned j = DAG.getTarget().getDataLayout()->isLittleEndian() ? 0 : 1;
862874 for (unsigned i = 0; i != 8; ++i)
863875 if (!isConstantOrUndef(N->getMaskElt(i), i*2+j) ||
864876 !isConstantOrUndef(N->getMaskElt(i+8), i*2+j))
869881
870882 /// isVPKUWUMShuffleMask - Return true if this is the shuffle mask for a
871883 /// VPKUWUM instruction.
872 bool PPC::isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, bool isUnary,
884 /// The ShuffleKind distinguishes between big-endian operations with
885 /// two different inputs (0), either-endian operations with two identical
886 /// inputs (1), and little-endian operantion with two different inputs (2).
887 /// For the latter, the input operands are swapped (see PPCInstrAltivec.td).
888 bool PPC::isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
873889 SelectionDAG &DAG) {
874 unsigned j, k;
875 if (DAG.getTarget().getDataLayout()->isLittleEndian()) {
876 j = 0;
877 k = 1;
878 } else {
879 j = 2;
880 k = 3;
881 }
882 if (!isUnary) {
890 if (ShuffleKind == 0) {
891 if (DAG.getTarget().getDataLayout()->isLittleEndian())
892 return false;
883893 for (unsigned i = 0; i != 16; i += 2)
884 if (!isConstantOrUndef(N->getMaskElt(i ), i*2+j) ||
885 !isConstantOrUndef(N->getMaskElt(i+1), i*2+k))
894 if (!isConstantOrUndef(N->getMaskElt(i ), i*2+2) ||
895 !isConstantOrUndef(N->getMaskElt(i+1), i*2+3))
886896 return false;
887 } else {
897 } else if (ShuffleKind == 2) {
898 if (!DAG.getTarget().getDataLayout()->isLittleEndian())
899 return false;
900 for (unsigned i = 0; i != 16; i += 2)
901 if (!isConstantOrUndef(N->getMaskElt(i ), i*2) ||
902 !isConstantOrUndef(N->getMaskElt(i+1), i*2+1))
903 return false;
904 } else if (ShuffleKind == 1) {
905 unsigned j = DAG.getTarget().getDataLayout()->isLittleEndian() ? 0 : 2;
888906 for (unsigned i = 0; i != 8; i += 2)
889 if (!isConstantOrUndef(N->getMaskElt(i ), i*2+j) ||
890 !isConstantOrUndef(N->getMaskElt(i+1), i*2+k) ||
891 !isConstantOrUndef(N->getMaskElt(i+8), i*2+j) ||
892 !isConstantOrUndef(N->getMaskElt(i+9), i*2+k))
907 if (!isConstantOrUndef(N->getMaskElt(i ), i*2+j) ||
908 !isConstantOrUndef(N->getMaskElt(i+1), i*2+j+1) ||
909 !isConstantOrUndef(N->getMaskElt(i+8), i*2+j) ||
910 !isConstantOrUndef(N->getMaskElt(i+9), i*2+j+1))
893911 return false;
894912 }
895913 return true;
60296047 if (PPC::isSplatShuffleMask(SVOp, 1) ||
60306048 PPC::isSplatShuffleMask(SVOp, 2) ||
60316049 PPC::isSplatShuffleMask(SVOp, 4) ||
6032 PPC::isVPKUWUMShuffleMask(SVOp, true, DAG) ||
6033 PPC::isVPKUHUMShuffleMask(SVOp, true, DAG) ||
6050 PPC::isVPKUWUMShuffleMask(SVOp, 1, DAG) ||
6051 PPC::isVPKUHUMShuffleMask(SVOp, 1, DAG) ||
60346052 PPC::isVSLDOIShuffleMask(SVOp, true, DAG) != -1 ||
60356053 PPC::isVMRGLShuffleMask(SVOp, 1, 1, DAG) ||
60366054 PPC::isVMRGLShuffleMask(SVOp, 2, 1, DAG) ||
60466064 // and produce a fixed permutation. If any of these match, do not lower to
60476065 // VPERM.
60486066 unsigned int ShuffleKind = isLittleEndian ? 2 : 0;
6049 if (PPC::isVPKUWUMShuffleMask(SVOp, false, DAG) ||
6050 PPC::isVPKUHUMShuffleMask(SVOp, false, DAG) ||
6067 if (PPC::isVPKUWUMShuffleMask(SVOp, ShuffleKind, DAG) ||
6068 PPC::isVPKUHUMShuffleMask(SVOp, ShuffleKind, DAG) ||
60516069 PPC::isVSLDOIShuffleMask(SVOp, false, DAG) != -1 ||
60526070 PPC::isVMRGLShuffleMask(SVOp, 1, ShuffleKind, DAG) ||
60536071 PPC::isVMRGLShuffleMask(SVOp, 2, ShuffleKind, DAG) ||
296296 namespace PPC {
297297 /// isVPKUHUMShuffleMask - Return true if this is the shuffle mask for a
298298 /// VPKUHUM instruction.
299 bool isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, bool isUnary,
299 bool isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
300300 SelectionDAG &DAG);
301301
302302 /// isVPKUWUMShuffleMask - Return true if this is the shuffle mask for a
303303 /// VPKUWUM instruction.
304 bool isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, bool isUnary,
304 bool isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
305305 SelectionDAG &DAG);
306306
307307 /// isVMRGLShuffleMask - Return true if this is a shuffle mask suitable for
2121
2222 def vpkuhum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
2323 (vector_shuffle node:$lhs, node:$rhs), [{
24 return PPC::isVPKUHUMShuffleMask(cast(N), false,
25 *CurDAG);
24 return PPC::isVPKUHUMShuffleMask(cast(N), 0, *CurDAG);
2625 }]>;
2726 def vpkuwum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
2827 (vector_shuffle node:$lhs, node:$rhs), [{
29 return PPC::isVPKUWUMShuffleMask(cast(N), false,
30 *CurDAG);
28 return PPC::isVPKUWUMShuffleMask(cast(N), 0, *CurDAG);
3129 }]>;
3230 def vpkuhum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
3331 (vector_shuffle node:$lhs, node:$rhs), [{
34 return PPC::isVPKUHUMShuffleMask(cast(N), true,
35 *CurDAG);
32 return PPC::isVPKUHUMShuffleMask(cast(N), 1, *CurDAG);
3633 }]>;
3734 def vpkuwum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
3835 (vector_shuffle node:$lhs, node:$rhs), [{
39 return PPC::isVPKUWUMShuffleMask(cast(N), true,
40 *CurDAG);
41 }]>;
42
36 return PPC::isVPKUWUMShuffleMask(cast(N), 1, *CurDAG);
37 }]>;
38
39 // These fragments are provided for little-endian, where the inputs must be
40 // swapped for correct semantics.
41 def vpkuhum_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
42 (vector_shuffle node:$lhs, node:$rhs), [{
43 return PPC::isVPKUHUMShuffleMask(cast(N), 2, *CurDAG);
44 }]>;
45 def vpkuwum_swapped_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
46 (vector_shuffle node:$lhs, node:$rhs), [{
47 return PPC::isVPKUWUMShuffleMask(cast(N), 2, *CurDAG);
48 }]>;
4349
4450 def vmrglb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
4551 (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
804810 def:Pat<(vpkuhum_unary_shuffle v16i8:$vA, undef),
805811 (VPKUHUM $vA, $vA)>;
806812
813 // Match vpkuwum(y,x), vpkuhum(y,x), i.e., swapped operands.
814 // These fragments are matched for little-endian, where the
815 // inputs must be swapped for correct semantics.
816 def:Pat<(vpkuwum_swapped_shuffle v16i8:$vA, v16i8:$vB),
817 (VPKUWUM $vB, $vA)>;
818 def:Pat<(vpkuhum_swapped_shuffle v16i8:$vA, v16i8:$vB),
819 (VPKUHUM $vB, $vA)>;
820
807821 // Match vmrg*(x,x)
808822 def:Pat<(vmrglb_unary_shuffle v16i8:$vA, undef),
809823 (VMRGLB $vA, $vA)>;
55 %tmp = load <16 x i8>* %A
66 %tmp2 = load <16 x i8>* %B
77 %tmp3 = shufflevector <16 x i8> %tmp, <16 x i8> %tmp2, <16 x i32>
8 ; CHECK: vpkuhum
8 ; CHECK: lvx [[REG1:[0-9]+]]
9 ; CHECK: lvx [[REG2:[0-9]+]]
10 ; CHECK: vpkuhum [[REG3:[0-9]+]], [[REG2]], [[REG1]]
911 store <16 x i8> %tmp3, <16 x i8>* %A
1012 ret void
1113 }
2628 %tmp = load <16 x i8>* %A
2729 %tmp2 = load <16 x i8>* %B
2830 %tmp3 = shufflevector <16 x i8> %tmp, <16 x i8> %tmp2, <16 x i32>
29 ; CHECK: vpkuwum
31 ; CHECK: lvx [[REG1:[0-9]+]]
32 ; CHECK: lvx [[REG2:[0-9]+]]
33 ; CHECK: vpkuwum [[REG3:[0-9]+]], [[REG2]], [[REG1]]
3034 store <16 x i8> %tmp3, <16 x i8>* %A
3135 ret void
3236 }