llvm.org GIT mirror
[CodeGen] Teach OR combine of shuffles involving zero vectors to better handle undef indices. Undef indices can now be treated as zeros. Or if its undef ORed with zero, we will keep the undef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274472 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 4 years ago
2 changed file(s) with 12 addition(s) and 11 deletion(s).
 3774 3774 int M0 = SV0->getMaskElt(i); 3775 3775 int M1 = SV1->getMaskElt(i); 3776 3776 3777 // Both shuffle indexes are undef. Propagate Undef. 3778 if (M0 < 0 && M1 < 0) {⏎ 3777 // Determine if either index is pointing to a zero vector.⏎ 3778 bool M0Zero = M0 < 0 || (ZeroN00 == (M0 < NumElts)); 3779 bool M1Zero = M1 < 0 || (ZeroN10 == (M1 < NumElts)); 3780 3781 // If one element is zero and the otherside is undef, keep undef. 3782 // This also handles the case that both are undef. 3783 if ((M0Zero && M1 < 0) || (M1Zero && M0 < 0)) { 3779 3784 Mask[i] = -1; 3780 3785 continue; 3781 3786 } 3782 3787 3783 // Determine if either index is pointing to a zero vector. 3784 bool M0Zero = M0 >= 0 && (ZeroN00 == (M0 < NumElts)); 3785 bool M1Zero = M1 >= 0 && (ZeroN10 == (M1 < NumElts));⏎ 3788 // Make sure only one of the elements is zero.⏎ 3786 3789 if (M0Zero == M1Zero) { 3787 3790 CanFold = false; 3788 3791 break; 3789 3792 } 3793 3794 assert((M0 >= 0 || M1 >= 0) && "Undef index!"); 3790 3795 3791 3796 // We have a zero and non-zero element. If the non-zero came from 3792 3797 // SV0 make the index a LHS index. If it came from SV1, make it
 396 396 define <4 x i32> @test2e(<4 x i32> %a, <4 x i32> %b) { 397 397 ; CHECK-LABEL: test2e: 398 398 ; CHECK: # BB#0: 399 ; CHECK-NEXT: pxor %xmm2, %xmm2 400 ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm2[2,3],xmm0[4,5,6,7] 401 ; CHECK-NEXT: movq {{.*#+}} xmm1 = xmm1[0],zero 402 ; CHECK-NEXT: por %xmm1, %xmm0⏎ 399 ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1,2,3],xmm0[4,5,6,7]⏎ 403 400 ; CHECK-NEXT: retq 404 401 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> , <4 x i32> 405 402 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> , <4 x i32> 410 407 define <4 x i32> @test2f(<4 x i32> %a, <4 x i32> %b) { 411 408 ; CHECK-LABEL: test2f: 412 409 ; CHECK: # BB#0: 413 ; CHECK-NEXT: pshufd {{.*#+}} xmm0 = xmm0[3,1,2,3] 414 ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7]⏎ 410 ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1,2,3],xmm0[4,5,6,7]⏎ 415 411 ; CHECK-NEXT: retq 416 412 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> , <4 x i32> 417 413 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> , <4 x i32>