llvm.org GIT mirror llvm / 798f284
[x86] Teach the rest of the 'target shuffle' machinery about blends and add VPBLENDD to the InstPrinter's comment generation so we get nice comments everywhere. Now that we have the nice comments, I can see the bug introduced by a silly typo in the commit that enabled VPBLENDD, and have fixed it. Yay tests that are easy to inspect. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218335 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 6 years ago
4 changed file(s) with 42 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
9696 case X86::VPBLENDWrmi:
9797 if(MI->getOperand(MI->getNumOperands()-1).isImm())
9898 DecodeBLENDMask(MVT::v8i16,
99 MI->getOperand(MI->getNumOperands()-1).getImm(),
100 ShuffleMask);
101 Src1Name = getRegName(MI->getOperand(1).getReg());
102 DestName = getRegName(MI->getOperand(0).getReg());
103 break;
104
105 case X86::VPBLENDDrri:
106 Src2Name = getRegName(MI->getOperand(2).getReg());
107 // FALL THROUGH.
108 case X86::VPBLENDDrmi:
109 if(MI->getOperand(MI->getNumOperands()-1).isImm())
110 DecodeBLENDMask(MVT::v4i32,
111 MI->getOperand(MI->getNumOperands()-1).getImm(),
112 ShuffleMask);
113 Src1Name = getRegName(MI->getOperand(1).getReg());
114 DestName = getRegName(MI->getOperand(0).getReg());
115 break;
116
117 case X86::VPBLENDDYrri:
118 Src2Name = getRegName(MI->getOperand(2).getReg());
119 // FALL THROUGH.
120 case X86::VPBLENDDYrmi:
121 if(MI->getOperand(MI->getNumOperands()-1).isImm())
122 DecodeBLENDMask(MVT::v8i32,
99123 MI->getOperand(MI->getNumOperands()-1).getImm(),
100124 ShuffleMask);
101125 Src1Name = getRegName(MI->getOperand(1).getReg());
35383538 static bool isTargetShuffle(unsigned Opcode) {
35393539 switch(Opcode) {
35403540 default: return false;
3541 case X86ISD::BLENDI:
35413542 case X86ISD::PSHUFB:
35423543 case X86ISD::PSHUFD:
35433544 case X86ISD::PSHUFHW:
52875288 IsUnary = false;
52885289 bool IsFakeUnary = false;
52895290 switch(N->getOpcode()) {
5291 case X86ISD::BLENDI:
5292 ImmN = N->getOperand(N->getNumOperands()-1);
5293 DecodeBLENDMask(VT, cast(ImmN)->getZExtValue(), Mask);
5294 break;
52905295 case X86ISD::SHUFP:
52915296 ImmN = N->getOperand(N->getNumOperands()-1);
52925297 DecodeSHUFPMask(VT, cast(ImmN)->getZExtValue(), Mask);
72697274 // If we have AVX2 it is faster to use VPBLENDD when the shuffle fits into
72707275 // that instruction.
72717276 if (Subtarget->hasAVX2()) {
7272 int Scale = 8 / VT.getVectorNumElements();
7277 int Scale = 4 / VT.getVectorNumElements();
72737278 BlendMask = 0;
72747279 for (int i = 0, Size = Mask.size(); i < Size; ++i)
72757280 if (Mask[i] >= Size)
715715 ; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm2
716716 ; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm3
717717 ; AVX2-NEXT: vpshuflw {{.*}} # xmm3 = xmm3[0,0,0,0,4,5,6,7]
718 ; AVX2-NEXT: vpblendd $-16, %xmm2, %xmm3, %xmm2
718 ; AVX2-NEXT: vpblendd {{.*}} # xmm2 = xmm3[0,1],xmm2[2,3]
719719 ; AVX2-NEXT: vpshuflw {{.*}} # xmm1 = xmm1[0,0,0,0,4,5,6,7]
720 ; AVX2-NEXT: vpblendd $-16, %xmm0, %xmm1, %xmm0
720 ; AVX2-NEXT: vpblendd {{.*}} # xmm0 = xmm1[0,1],xmm0[2,3]
721721 ; AVX2-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0
722722 ; AVX2-NEXT: retq
723723 %shuffle = shufflevector <16 x i16> %a, <16 x i16> %b, <16 x i32>
744744 ; AVX2-NEXT: vpshufhw {{.*}} # xmm2 = xmm2[0,1,2,3,7,6,5,4]
745745 ; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm3
746746 ; AVX2-NEXT: vpshuflw {{.*}} # xmm3 = xmm3[3,2,1,0,4,5,6,7]
747 ; AVX2-NEXT: vpblendd $-16, %xmm2, %xmm3, %xmm2
747 ; AVX2-NEXT: vpblendd {{.*}} # xmm2 = xmm3[0,1],xmm2[2,3]
748748 ; AVX2-NEXT: vpshufhw {{.*}} # xmm0 = xmm0[0,1,2,3,7,6,5,4]
749749 ; AVX2-NEXT: vpshuflw {{.*}} # xmm1 = xmm1[3,2,1,0,4,5,6,7]
750 ; AVX2-NEXT: vpblendd $-16, %xmm0, %xmm1, %xmm0
750 ; AVX2-NEXT: vpblendd {{.*}} # xmm0 = xmm1[0,1],xmm0[2,3]
751751 ; AVX2-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0
752752 ; AVX2-NEXT: retq
753753 %shuffle = shufflevector <16 x i16> %a, <16 x i16> %b, <16 x i32>
777777 ; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm3
778778 ; AVX2-NEXT: vpshufd {{.*}} # xmm3 = xmm3[0,1,0,1]
779779 ; AVX2-NEXT: vpshufhw {{.*}} # xmm3 = xmm3[0,1,2,3,7,6,5,4]
780 ; AVX2-NEXT: vpblendd $-16, %xmm3, %xmm2, %xmm2
780 ; AVX2-NEXT: vpblendd {{.*}} # xmm2 = xmm2[0,1],xmm3[2,3]
781781 ; AVX2-NEXT: vpshuflw {{.*}} # xmm1 = xmm1[3,2,1,0,4,5,6,7]
782782 ; AVX2-NEXT: vpshufd {{.*}} # xmm0 = xmm0[0,1,0,1]
783783 ; AVX2-NEXT: vpshufhw {{.*}} # xmm0 = xmm0[0,1,2,3,7,6,5,4]
784 ; AVX2-NEXT: vpblendd $-16, %xmm0, %xmm1, %xmm0
784 ; AVX2-NEXT: vpblendd {{.*}} # xmm0 = xmm1[0,1],xmm0[2,3]
785785 ; AVX2-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0
786786 ; AVX2-NEXT: retq
787787 %shuffle = shufflevector <16 x i16> %a, <16 x i16> %b, <16 x i32>
11371137 ; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm4
11381138 ; AVX2-NEXT: vpunpcklbw {{.*}} # xmm4 = xmm4[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
11391139 ; AVX2-NEXT: vpshuflw {{.*}} # xmm4 = xmm4[0,0,0,0,4,5,6,7]
1140 ; AVX2-NEXT: vpblendd $-16, %xmm2, %xmm4, %xmm2
1140 ; AVX2-NEXT: vpblendd {{.*}} # xmm2 = xmm4[0,1],xmm2[2,3]
11411141 ; AVX2-NEXT: vpshufb %xmm3, %xmm0, %xmm0
11421142 ; AVX2-NEXT: vpunpcklbw {{.*}} # xmm1 = xmm1[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
11431143 ; AVX2-NEXT: vpshuflw {{.*}} # xmm1 = xmm1[0,0,0,0,4,5,6,7]
1144 ; AVX2-NEXT: vpblendd $-16, %xmm0, %xmm1, %xmm0
1144 ; AVX2-NEXT: vpblendd {{.*}} # xmm0 = xmm1[0,1],xmm0[2,3]
11451145 ; AVX2-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0
11461146 ; AVX2-NEXT: retq
11471147 %shuffle = shufflevector <32 x i8> %a, <32 x i8> %b, <32 x i32>
11721172 ; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm4
11731173 ; AVX2-NEXT: vmovdqa .LCPI50_1(%rip), %xmm5
11741174 ; AVX2-NEXT: vpshufb %xmm5, %xmm4, %xmm4
1175 ; AVX2-NEXT: vpblendd $-16, %xmm2, %xmm4, %xmm2
1175 ; AVX2-NEXT: vpblendd {{.*}} # xmm2 = xmm4[0,1],xmm2[2,3]
11761176 ; AVX2-NEXT: vpshufb %xmm3, %xmm0, %xmm0
11771177 ; AVX2-NEXT: vpshufb %xmm5, %xmm1, %xmm1
1178 ; AVX2-NEXT: vpblendd $-16, %xmm0, %xmm1, %xmm0
1178 ; AVX2-NEXT: vpblendd {{.*}} # xmm0 = xmm1[0,1],xmm0[2,3]
11791179 ; AVX2-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0
11801180 ; AVX2-NEXT: retq
11811181 %shuffle = shufflevector <32 x i8> %a, <32 x i8> %b, <32 x i32>
12061206 ; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm4
12071207 ; AVX2-NEXT: vmovdqa .LCPI51_1(%rip), %xmm5
12081208 ; AVX2-NEXT: vpshufb %xmm5, %xmm4, %xmm4
1209 ; AVX2-NEXT: vpblendd $-16, %xmm2, %xmm4, %xmm2
1209 ; AVX2-NEXT: vpblendd {{.*}} # xmm2 = xmm4[0,1],xmm2[2,3]
12101210 ; AVX2-NEXT: vpshufb %xmm3, %xmm0, %xmm0
12111211 ; AVX2-NEXT: vpshufb %xmm5, %xmm1, %xmm1
1212 ; AVX2-NEXT: vpblendd $-16, %xmm0, %xmm1, %xmm0
1212 ; AVX2-NEXT: vpblendd {{.*}} # xmm0 = xmm1[0,1],xmm0[2,3]
12131213 ; AVX2-NEXT: vinserti128 $1, %xmm2, %ymm0, %ymm0
12141214 ; AVX2-NEXT: retq
12151215 %shuffle = shufflevector <32 x i8> %a, <32 x i8> %b, <32 x i32>