Skip to content

Commit 7efc7ca

Browse files
committed
[X86][SSE] Add knownbits test showing missing getValidMinimumShiftAmountConstant() ISD::SHL support
As mentioned on D72573
1 parent b96ec49 commit 7efc7ca

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

llvm/test/CodeGen/X86/combine-shl.ll

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,3 +832,36 @@ define <4 x i32> @combine_vec_shl_mul1(<4 x i32> %x) {
832832
%2 = shl <4 x i32> %1, <i32 1, i32 2, i32 3, i32 4>
833833
ret <4 x i32> %2
834834
}
835+
836+
; fold (add (shl x, c1), c2) -> (or (shl x, c1), c2)
837+
; TODO: Handle minimum shift value case
838+
define <4 x i32> @combine_vec_add_shl_nonsplat(<4 x i32> %a0) {
839+
; SSE2-LABEL: combine_vec_add_shl_nonsplat:
840+
; SSE2: # %bb.0:
841+
; SSE2-NEXT: movdqa {{.*#+}} xmm1 = [4,8,16,32]
842+
; SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm0[1,1,3,3]
843+
; SSE2-NEXT: pmuludq %xmm1, %xmm0
844+
; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
845+
; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
846+
; SSE2-NEXT: pmuludq %xmm2, %xmm1
847+
; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
848+
; SSE2-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
849+
; SSE2-NEXT: paddd {{.*}}(%rip), %xmm0
850+
; SSE2-NEXT: retq
851+
;
852+
; SSE41-LABEL: combine_vec_add_shl_nonsplat:
853+
; SSE41: # %bb.0:
854+
; SSE41-NEXT: pmulld {{.*}}(%rip), %xmm0
855+
; SSE41-NEXT: por {{.*}}(%rip), %xmm0
856+
; SSE41-NEXT: retq
857+
;
858+
; AVX-LABEL: combine_vec_add_shl_nonsplat:
859+
; AVX: # %bb.0:
860+
; AVX-NEXT: vpsllvd {{.*}}(%rip), %xmm0, %xmm0
861+
; AVX-NEXT: vpbroadcastd {{.*#+}} xmm1 = [3,3,3,3]
862+
; AVX-NEXT: vpaddd %xmm1, %xmm0, %xmm0
863+
; AVX-NEXT: retq
864+
%1 = shl <4 x i32> %a0, <i32 2, i32 3, i32 4, i32 5>
865+
%2 = add <4 x i32> %1, <i32 3, i32 3, i32 3, i32 3>
866+
ret <4 x i32> %2
867+
}

0 commit comments

Comments
 (0)