1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=bdver2 | FileCheck %s --check-prefixes=CHECK,XOP,XOPAVX1
3 ; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=bdver4 | FileCheck %s --check-prefixes=CHECK,XOP,XOPAVX2
4 ; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=skylake-avx512 | FileCheck %s --check-prefixes=CHECK,AVX512
6 define <4 x i32> @rot_v4i32_splat(<4 x i32> %x) {
7 ; XOP-LABEL: rot_v4i32_splat:
9 ; XOP-NEXT: vprotd $31, %xmm0, %xmm0
12 ; AVX512-LABEL: rot_v4i32_splat:
14 ; AVX512-NEXT: vprold $31, %xmm0, %xmm0
16 %1 = lshr <4 x i32> %x, <i32 1, i32 1, i32 1, i32 1>
17 %2 = shl <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
18 %3 = or <4 x i32> %1, %2
22 define <4 x i32> @rot_v4i32_non_splat(<4 x i32> %x) {
23 ; XOP-LABEL: rot_v4i32_non_splat:
25 ; XOP-NEXT: vprotd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
28 ; AVX512-LABEL: rot_v4i32_non_splat:
30 ; AVX512-NEXT: vprolvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
32 %1 = lshr <4 x i32> %x, <i32 1, i32 2, i32 3, i32 4>
33 %2 = shl <4 x i32> %x, <i32 31, i32 30, i32 29, i32 28>
34 %3 = or <4 x i32> %1, %2
38 define <4 x i32> @rot_v4i32_splat_2masks(<4 x i32> %x) {
39 ; XOP-LABEL: rot_v4i32_splat_2masks:
41 ; XOP-NEXT: vprotd $31, %xmm0, %xmm0
42 ; XOP-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
45 ; AVX512-LABEL: rot_v4i32_splat_2masks:
47 ; AVX512-NEXT: vprold $31, %xmm0, %xmm0
48 ; AVX512-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
50 %1 = lshr <4 x i32> %x, <i32 1, i32 1, i32 1, i32 1>
51 %2 = and <4 x i32> %1, <i32 4294901760, i32 4294901760, i32 4294901760, i32 4294901760>
53 %3 = shl <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
54 %4 = and <4 x i32> %3, <i32 0, i32 4294901760, i32 0, i32 4294901760>
55 %5 = or <4 x i32> %2, %4
59 define <4 x i32> @rot_v4i32_non_splat_2masks(<4 x i32> %x) {
60 ; XOP-LABEL: rot_v4i32_non_splat_2masks:
62 ; XOP-NEXT: vprotd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
63 ; XOP-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
66 ; AVX512-LABEL: rot_v4i32_non_splat_2masks:
68 ; AVX512-NEXT: vprolvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
69 ; AVX512-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
71 %1 = lshr <4 x i32> %x, <i32 1, i32 2, i32 3, i32 4>
72 %2 = and <4 x i32> %1, <i32 4294901760, i32 4294901760, i32 4294901760, i32 4294901760>
74 %3 = shl <4 x i32> %x, <i32 31, i32 30, i32 29, i32 28>
75 %4 = and <4 x i32> %3, <i32 0, i32 4294901760, i32 0, i32 4294901760>
76 %5 = or <4 x i32> %2, %4
80 define <4 x i32> @rot_v4i32_zero_non_splat(<4 x i32> %x) {
81 ; XOPAVX1-LABEL: rot_v4i32_zero_non_splat:
83 ; XOPAVX1-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
86 ; XOPAVX2-LABEL: rot_v4i32_zero_non_splat:
88 ; XOPAVX2-NEXT: vbroadcastss %xmm0, %xmm0
91 ; AVX512-LABEL: rot_v4i32_zero_non_splat:
93 ; AVX512-NEXT: vbroadcastss %xmm0, %xmm0
95 %1 = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %x, <4 x i32> %x, <4 x i32> <i32 0, i32 1, i32 2, i32 3>)
96 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> zeroinitializer
100 define <4 x i32> @rot_v4i32_allsignbits(<4 x i32> %x, <4 x i32> %y) {
101 ; CHECK-LABEL: rot_v4i32_allsignbits:
103 ; CHECK-NEXT: vpsrad $31, %xmm0, %xmm0
105 %1 = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
106 %2 = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %1, <4 x i32> %1, <4 x i32> %y)
110 define <4 x i32> @rot_v4i32_mask_ashr0(<4 x i32> %a0) {
111 ; XOPAVX1-LABEL: rot_v4i32_mask_ashr0:
113 ; XOPAVX1-NEXT: vpshad {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
114 ; XOPAVX1-NEXT: vprotd $1, %xmm0, %xmm0
115 ; XOPAVX1-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
118 ; XOPAVX2-LABEL: rot_v4i32_mask_ashr0:
120 ; XOPAVX2-NEXT: vpsravd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
121 ; XOPAVX2-NEXT: vprotd $1, %xmm0, %xmm0
122 ; XOPAVX2-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
125 ; AVX512-LABEL: rot_v4i32_mask_ashr0:
127 ; AVX512-NEXT: vpsravd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
128 ; AVX512-NEXT: vprold $1, %xmm0, %xmm0
129 ; AVX512-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
131 %1 = ashr <4 x i32> %a0, <i32 25, i32 26, i32 27, i32 28>
132 %2 = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %1, <4 x i32> %1, <4 x i32> <i32 1, i32 1, i32 1, i32 1>)
133 %3 = ashr <4 x i32> %2, <i32 1, i32 2, i32 3, i32 4>
134 %4 = and <4 x i32> %3, <i32 -32768, i32 -65536, i32 -32768, i32 -65536>
138 define <4 x i32> @rot_v4i32_mask_ashr1(<4 x i32> %a0) {
139 ; XOPAVX1-LABEL: rot_v4i32_mask_ashr1:
141 ; XOPAVX1-NEXT: vpsrad $25, %xmm0, %xmm0
142 ; XOPAVX1-NEXT: vprotd $1, %xmm0, %xmm0
143 ; XOPAVX1-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,0,0]
144 ; XOPAVX1-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
147 ; XOPAVX2-LABEL: rot_v4i32_mask_ashr1:
149 ; XOPAVX2-NEXT: vpsrad $25, %xmm0, %xmm0
150 ; XOPAVX2-NEXT: vprotd $1, %xmm0, %xmm0
151 ; XOPAVX2-NEXT: vpbroadcastd %xmm0, %xmm0
152 ; XOPAVX2-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
155 ; AVX512-LABEL: rot_v4i32_mask_ashr1:
157 ; AVX512-NEXT: vpsrad $25, %xmm0, %xmm0
158 ; AVX512-NEXT: vprold $1, %xmm0, %xmm0
159 ; AVX512-NEXT: vpbroadcastd %xmm0, %xmm0
160 ; AVX512-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
162 %1 = ashr <4 x i32> %a0, <i32 25, i32 26, i32 27, i32 28>
163 %2 = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %1, <4 x i32> %1, <4 x i32> <i32 1, i32 2, i32 3, i32 4>)
164 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> zeroinitializer
165 %4 = ashr <4 x i32> %3, <i32 1, i32 2, i32 3, i32 4>
166 %5 = and <4 x i32> %4, <i32 -4096, i32 -8192, i32 -4096, i32 -8192>
170 declare <4 x i32> @llvm.fshl.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)