• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=x86-64 -mattr=+bmi2 | FileCheck %s --check-prefix=CHECK --check-prefix=GENERIC
3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=haswell | FileCheck %s --check-prefix=CHECK --check-prefix=HASWELL
4; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=broadwell | FileCheck %s --check-prefix=CHECK --check-prefix=BROADWELL
5; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=skylake | FileCheck %s --check-prefix=CHECK --check-prefix=SKYLAKE
6; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=knl     | FileCheck %s --check-prefix=CHECK --check-prefix=KNL
7; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=znver1  | FileCheck %s --check-prefix=CHECK --check-prefix=ZNVER1
8
9define i32 @test_bzhi_i32(i32 %a0, i32 %a1, i32 *%a2) {
10; GENERIC-LABEL: test_bzhi_i32:
11; GENERIC:       # %bb.0:
12; GENERIC-NEXT:    bzhil %edi, (%rdx), %ecx # sched: [6:1.00]
13; GENERIC-NEXT:    bzhil %edi, %esi, %eax # sched: [1:1.00]
14; GENERIC-NEXT:    addl %ecx, %eax # sched: [1:0.33]
15; GENERIC-NEXT:    retq # sched: [1:1.00]
16;
17; HASWELL-LABEL: test_bzhi_i32:
18; HASWELL:       # %bb.0:
19; HASWELL-NEXT:    bzhil %edi, (%rdx), %ecx # sched: [6:0.50]
20; HASWELL-NEXT:    bzhil %edi, %esi, %eax # sched: [1:0.50]
21; HASWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
22; HASWELL-NEXT:    retq # sched: [7:1.00]
23;
24; BROADWELL-LABEL: test_bzhi_i32:
25; BROADWELL:       # %bb.0:
26; BROADWELL-NEXT:    bzhil %edi, (%rdx), %ecx # sched: [6:0.50]
27; BROADWELL-NEXT:    bzhil %edi, %esi, %eax # sched: [1:0.50]
28; BROADWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
29; BROADWELL-NEXT:    retq # sched: [7:1.00]
30;
31; SKYLAKE-LABEL: test_bzhi_i32:
32; SKYLAKE:       # %bb.0:
33; SKYLAKE-NEXT:    bzhil %edi, (%rdx), %ecx # sched: [6:0.50]
34; SKYLAKE-NEXT:    bzhil %edi, %esi, %eax # sched: [1:0.50]
35; SKYLAKE-NEXT:    addl %ecx, %eax # sched: [1:0.25]
36; SKYLAKE-NEXT:    retq # sched: [7:1.00]
37;
38; KNL-LABEL: test_bzhi_i32:
39; KNL:       # %bb.0:
40; KNL-NEXT:    bzhil %edi, (%rdx), %ecx # sched: [6:0.50]
41; KNL-NEXT:    bzhil %edi, %esi, %eax # sched: [1:0.50]
42; KNL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
43; KNL-NEXT:    retq # sched: [7:1.00]
44;
45; ZNVER1-LABEL: test_bzhi_i32:
46; ZNVER1:       # %bb.0:
47; ZNVER1-NEXT:    bzhil %edi, (%rdx), %ecx # sched: [5:0.50]
48; ZNVER1-NEXT:    bzhil %edi, %esi, %eax # sched: [1:0.25]
49; ZNVER1-NEXT:    addl %ecx, %eax # sched: [1:0.25]
50; ZNVER1-NEXT:    retq # sched: [1:0.50]
51  %1 = load i32, i32 *%a2
52  %2 = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %1, i32 %a0)
53  %3 = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %a1, i32 %a0)
54  %4 = add i32 %2, %3
55  ret i32 %4
56}
57declare i32 @llvm.x86.bmi.bzhi.32(i32, i32)
58
59define i64 @test_bzhi_i64(i64 %a0, i64 %a1, i64 *%a2) {
60; GENERIC-LABEL: test_bzhi_i64:
61; GENERIC:       # %bb.0:
62; GENERIC-NEXT:    bzhiq %rdi, (%rdx), %rcx # sched: [6:1.00]
63; GENERIC-NEXT:    bzhiq %rdi, %rsi, %rax # sched: [1:1.00]
64; GENERIC-NEXT:    addq %rcx, %rax # sched: [1:0.33]
65; GENERIC-NEXT:    retq # sched: [1:1.00]
66;
67; HASWELL-LABEL: test_bzhi_i64:
68; HASWELL:       # %bb.0:
69; HASWELL-NEXT:    bzhiq %rdi, (%rdx), %rcx # sched: [6:0.50]
70; HASWELL-NEXT:    bzhiq %rdi, %rsi, %rax # sched: [1:0.50]
71; HASWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
72; HASWELL-NEXT:    retq # sched: [7:1.00]
73;
74; BROADWELL-LABEL: test_bzhi_i64:
75; BROADWELL:       # %bb.0:
76; BROADWELL-NEXT:    bzhiq %rdi, (%rdx), %rcx # sched: [6:0.50]
77; BROADWELL-NEXT:    bzhiq %rdi, %rsi, %rax # sched: [1:0.50]
78; BROADWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
79; BROADWELL-NEXT:    retq # sched: [7:1.00]
80;
81; SKYLAKE-LABEL: test_bzhi_i64:
82; SKYLAKE:       # %bb.0:
83; SKYLAKE-NEXT:    bzhiq %rdi, (%rdx), %rcx # sched: [6:0.50]
84; SKYLAKE-NEXT:    bzhiq %rdi, %rsi, %rax # sched: [1:0.50]
85; SKYLAKE-NEXT:    addq %rcx, %rax # sched: [1:0.25]
86; SKYLAKE-NEXT:    retq # sched: [7:1.00]
87;
88; KNL-LABEL: test_bzhi_i64:
89; KNL:       # %bb.0:
90; KNL-NEXT:    bzhiq %rdi, (%rdx), %rcx # sched: [6:0.50]
91; KNL-NEXT:    bzhiq %rdi, %rsi, %rax # sched: [1:0.50]
92; KNL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
93; KNL-NEXT:    retq # sched: [7:1.00]
94;
95; ZNVER1-LABEL: test_bzhi_i64:
96; ZNVER1:       # %bb.0:
97; ZNVER1-NEXT:    bzhiq %rdi, (%rdx), %rcx # sched: [5:0.50]
98; ZNVER1-NEXT:    bzhiq %rdi, %rsi, %rax # sched: [1:0.25]
99; ZNVER1-NEXT:    addq %rcx, %rax # sched: [1:0.25]
100; ZNVER1-NEXT:    retq # sched: [1:0.50]
101  %1 = load i64, i64 *%a2
102  %2 = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %1, i64 %a0)
103  %3 = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %a1, i64 %a0)
104  %4 = add i64 %2, %3
105  ret i64 %4
106}
107declare i64 @llvm.x86.bmi.bzhi.64(i64, i64)
108
109define void @test_mulx_i32(i32 %a0, i32 %a1, i32* %a2) optsize {
110; GENERIC-LABEL: test_mulx_i32:
111; GENERIC:       # %bb.0:
112; GENERIC-NEXT:    #APP
113; GENERIC-NEXT:    mulxl %esi, %esi, %edi # sched: [3:1.00]
114; GENERIC-NEXT:    mulxl (%rdx), %esi, %edi # sched: [8:1.00]
115; GENERIC-NEXT:    #NO_APP
116; GENERIC-NEXT:    retq # sched: [1:1.00]
117;
118; HASWELL-LABEL: test_mulx_i32:
119; HASWELL:       # %bb.0:
120; HASWELL-NEXT:    #APP
121; HASWELL-NEXT:    mulxl %esi, %esi, %edi # sched: [4:1.00]
122; HASWELL-NEXT:    mulxl (%rdx), %esi, %edi # sched: [9:1.00]
123; HASWELL-NEXT:    #NO_APP
124; HASWELL-NEXT:    retq # sched: [7:1.00]
125;
126; BROADWELL-LABEL: test_mulx_i32:
127; BROADWELL:       # %bb.0:
128; BROADWELL-NEXT:    #APP
129; BROADWELL-NEXT:    mulxl %esi, %esi, %edi # sched: [4:1.00]
130; BROADWELL-NEXT:    mulxl (%rdx), %esi, %edi # sched: [9:1.00]
131; BROADWELL-NEXT:    #NO_APP
132; BROADWELL-NEXT:    retq # sched: [7:1.00]
133;
134; SKYLAKE-LABEL: test_mulx_i32:
135; SKYLAKE:       # %bb.0:
136; SKYLAKE-NEXT:    #APP
137; SKYLAKE-NEXT:    mulxl %esi, %esi, %edi # sched: [4:1.00]
138; SKYLAKE-NEXT:    mulxl (%rdx), %esi, %edi # sched: [9:1.00]
139; SKYLAKE-NEXT:    #NO_APP
140; SKYLAKE-NEXT:    retq # sched: [7:1.00]
141;
142; KNL-LABEL: test_mulx_i32:
143; KNL:       # %bb.0:
144; KNL-NEXT:    #APP
145; KNL-NEXT:    mulxl %esi, %esi, %edi # sched: [4:1.00]
146; KNL-NEXT:    mulxl (%rdx), %esi, %edi # sched: [9:1.00]
147; KNL-NEXT:    #NO_APP
148; KNL-NEXT:    retq # sched: [7:1.00]
149;
150; ZNVER1-LABEL: test_mulx_i32:
151; ZNVER1:       # %bb.0:
152; ZNVER1-NEXT:    #APP
153; ZNVER1-NEXT:    mulxl %esi, %esi, %edi # sched: [3:2.00]
154; ZNVER1-NEXT:    mulxl (%rdx), %esi, %edi # sched: [8:2.00]
155; ZNVER1-NEXT:    #NO_APP
156; ZNVER1-NEXT:    retq # sched: [1:0.50]
157  tail call void asm "mulx $1, $1, $0 \0A\09 mulx $2, $1, $0 ", "r,r,*m"(i32 %a0, i32 %a1, i32* %a2) nounwind
158  ret void
159}
160
161define i64 @test_mulx_i64(i64 %a0, i64 %a1, i64 *%a2) {
162; GENERIC-LABEL: test_mulx_i64:
163; GENERIC:       # %bb.0:
164; GENERIC-NEXT:    movq %rdx, %rax # sched: [1:0.33]
165; GENERIC-NEXT:    movq %rdi, %rdx # sched: [1:0.33]
166; GENERIC-NEXT:    mulxq %rsi, %rsi, %rcx # sched: [3:1.00]
167; GENERIC-NEXT:    mulxq (%rax), %rdx, %rax # sched: [8:1.00]
168; GENERIC-NEXT:    orq %rcx, %rax # sched: [1:0.33]
169; GENERIC-NEXT:    retq # sched: [1:1.00]
170;
171; HASWELL-LABEL: test_mulx_i64:
172; HASWELL:       # %bb.0:
173; HASWELL-NEXT:    movq %rdx, %rax # sched: [1:0.25]
174; HASWELL-NEXT:    movq %rdi, %rdx # sched: [1:0.25]
175; HASWELL-NEXT:    mulxq %rsi, %rsi, %rcx # sched: [4:1.00]
176; HASWELL-NEXT:    mulxq (%rax), %rdx, %rax # sched: [9:1.00]
177; HASWELL-NEXT:    orq %rcx, %rax # sched: [1:0.25]
178; HASWELL-NEXT:    retq # sched: [7:1.00]
179;
180; BROADWELL-LABEL: test_mulx_i64:
181; BROADWELL:       # %bb.0:
182; BROADWELL-NEXT:    movq %rdx, %rax # sched: [1:0.25]
183; BROADWELL-NEXT:    movq %rdi, %rdx # sched: [1:0.25]
184; BROADWELL-NEXT:    mulxq %rsi, %rsi, %rcx # sched: [4:1.00]
185; BROADWELL-NEXT:    mulxq (%rax), %rdx, %rax # sched: [9:1.00]
186; BROADWELL-NEXT:    orq %rcx, %rax # sched: [1:0.25]
187; BROADWELL-NEXT:    retq # sched: [7:1.00]
188;
189; SKYLAKE-LABEL: test_mulx_i64:
190; SKYLAKE:       # %bb.0:
191; SKYLAKE-NEXT:    movq %rdx, %rax # sched: [1:0.25]
192; SKYLAKE-NEXT:    movq %rdi, %rdx # sched: [1:0.25]
193; SKYLAKE-NEXT:    mulxq %rsi, %rsi, %rcx # sched: [4:1.00]
194; SKYLAKE-NEXT:    mulxq (%rax), %rdx, %rax # sched: [9:1.00]
195; SKYLAKE-NEXT:    orq %rcx, %rax # sched: [1:0.25]
196; SKYLAKE-NEXT:    retq # sched: [7:1.00]
197;
198; KNL-LABEL: test_mulx_i64:
199; KNL:       # %bb.0:
200; KNL-NEXT:    movq %rdx, %rax # sched: [1:0.25]
201; KNL-NEXT:    movq %rdi, %rdx # sched: [1:0.25]
202; KNL-NEXT:    mulxq %rsi, %rsi, %rcx # sched: [4:1.00]
203; KNL-NEXT:    mulxq (%rax), %rdx, %rax # sched: [9:1.00]
204; KNL-NEXT:    orq %rcx, %rax # sched: [1:0.25]
205; KNL-NEXT:    retq # sched: [7:1.00]
206;
207; ZNVER1-LABEL: test_mulx_i64:
208; ZNVER1:       # %bb.0:
209; ZNVER1-NEXT:    movq %rdx, %rax # sched: [1:0.25]
210; ZNVER1-NEXT:    movq %rdi, %rdx # sched: [1:0.25]
211; ZNVER1-NEXT:    mulxq %rsi, %rsi, %rcx # sched: [3:1.00]
212; ZNVER1-NEXT:    mulxq (%rax), %rdx, %rax # sched: [8:1.00]
213; ZNVER1-NEXT:    orq %rcx, %rax # sched: [1:0.25]
214; ZNVER1-NEXT:    retq # sched: [1:0.50]
215  %1  = load i64, i64 *%a2
216  %2  = zext i64 %a0 to i128
217  %3  = zext i64 %a1 to i128
218  %4  = zext i64 %1 to i128
219  %5  = mul i128 %2, %3
220  %6  = mul i128 %2, %4
221  %7  = lshr i128 %5, 64
222  %8  = lshr i128 %6, 64
223  %9  = trunc i128 %7 to i64
224  %10 = trunc i128 %8 to i64
225  %11 = or i64 %9, %10
226  ret i64 %11
227}
228
229define i32 @test_pdep_i32(i32 %a0, i32 %a1, i32 *%a2) {
230; GENERIC-LABEL: test_pdep_i32:
231; GENERIC:       # %bb.0:
232; GENERIC-NEXT:    pdepl (%rdx), %edi, %ecx # sched: [6:0.50]
233; GENERIC-NEXT:    pdepl %esi, %edi, %eax # sched: [1:0.33]
234; GENERIC-NEXT:    addl %ecx, %eax # sched: [1:0.33]
235; GENERIC-NEXT:    retq # sched: [1:1.00]
236;
237; HASWELL-LABEL: test_pdep_i32:
238; HASWELL:       # %bb.0:
239; HASWELL-NEXT:    pdepl (%rdx), %edi, %ecx # sched: [8:1.00]
240; HASWELL-NEXT:    pdepl %esi, %edi, %eax # sched: [3:1.00]
241; HASWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
242; HASWELL-NEXT:    retq # sched: [7:1.00]
243;
244; BROADWELL-LABEL: test_pdep_i32:
245; BROADWELL:       # %bb.0:
246; BROADWELL-NEXT:    pdepl (%rdx), %edi, %ecx # sched: [8:1.00]
247; BROADWELL-NEXT:    pdepl %esi, %edi, %eax # sched: [3:1.00]
248; BROADWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
249; BROADWELL-NEXT:    retq # sched: [7:1.00]
250;
251; SKYLAKE-LABEL: test_pdep_i32:
252; SKYLAKE:       # %bb.0:
253; SKYLAKE-NEXT:    pdepl (%rdx), %edi, %ecx # sched: [8:1.00]
254; SKYLAKE-NEXT:    pdepl %esi, %edi, %eax # sched: [3:1.00]
255; SKYLAKE-NEXT:    addl %ecx, %eax # sched: [1:0.25]
256; SKYLAKE-NEXT:    retq # sched: [7:1.00]
257;
258; KNL-LABEL: test_pdep_i32:
259; KNL:       # %bb.0:
260; KNL-NEXT:    pdepl (%rdx), %edi, %ecx # sched: [8:1.00]
261; KNL-NEXT:    pdepl %esi, %edi, %eax # sched: [3:1.00]
262; KNL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
263; KNL-NEXT:    retq # sched: [7:1.00]
264;
265; ZNVER1-LABEL: test_pdep_i32:
266; ZNVER1:       # %bb.0:
267; ZNVER1-NEXT:    pdepl (%rdx), %edi, %ecx # sched: [100:0.25]
268; ZNVER1-NEXT:    pdepl %esi, %edi, %eax # sched: [100:0.25]
269; ZNVER1-NEXT:    addl %ecx, %eax # sched: [1:0.25]
270; ZNVER1-NEXT:    retq # sched: [1:0.50]
271  %1 = load i32, i32 *%a2
272  %2 = tail call i32 @llvm.x86.bmi.pdep.32(i32 %a0, i32 %1)
273  %3 = tail call i32 @llvm.x86.bmi.pdep.32(i32 %a0, i32 %a1)
274  %4 = add i32 %2, %3
275  ret i32 %4
276}
277declare i32 @llvm.x86.bmi.pdep.32(i32, i32)
278
279define i64 @test_pdep_i64(i64 %a0, i64 %a1, i64 *%a2) {
280; GENERIC-LABEL: test_pdep_i64:
281; GENERIC:       # %bb.0:
282; GENERIC-NEXT:    pdepq (%rdx), %rdi, %rcx # sched: [6:0.50]
283; GENERIC-NEXT:    pdepq %rsi, %rdi, %rax # sched: [1:0.33]
284; GENERIC-NEXT:    addq %rcx, %rax # sched: [1:0.33]
285; GENERIC-NEXT:    retq # sched: [1:1.00]
286;
287; HASWELL-LABEL: test_pdep_i64:
288; HASWELL:       # %bb.0:
289; HASWELL-NEXT:    pdepq (%rdx), %rdi, %rcx # sched: [8:1.00]
290; HASWELL-NEXT:    pdepq %rsi, %rdi, %rax # sched: [3:1.00]
291; HASWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
292; HASWELL-NEXT:    retq # sched: [7:1.00]
293;
294; BROADWELL-LABEL: test_pdep_i64:
295; BROADWELL:       # %bb.0:
296; BROADWELL-NEXT:    pdepq (%rdx), %rdi, %rcx # sched: [8:1.00]
297; BROADWELL-NEXT:    pdepq %rsi, %rdi, %rax # sched: [3:1.00]
298; BROADWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
299; BROADWELL-NEXT:    retq # sched: [7:1.00]
300;
301; SKYLAKE-LABEL: test_pdep_i64:
302; SKYLAKE:       # %bb.0:
303; SKYLAKE-NEXT:    pdepq (%rdx), %rdi, %rcx # sched: [8:1.00]
304; SKYLAKE-NEXT:    pdepq %rsi, %rdi, %rax # sched: [3:1.00]
305; SKYLAKE-NEXT:    addq %rcx, %rax # sched: [1:0.25]
306; SKYLAKE-NEXT:    retq # sched: [7:1.00]
307;
308; KNL-LABEL: test_pdep_i64:
309; KNL:       # %bb.0:
310; KNL-NEXT:    pdepq (%rdx), %rdi, %rcx # sched: [8:1.00]
311; KNL-NEXT:    pdepq %rsi, %rdi, %rax # sched: [3:1.00]
312; KNL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
313; KNL-NEXT:    retq # sched: [7:1.00]
314;
315; ZNVER1-LABEL: test_pdep_i64:
316; ZNVER1:       # %bb.0:
317; ZNVER1-NEXT:    pdepq (%rdx), %rdi, %rcx # sched: [100:0.25]
318; ZNVER1-NEXT:    pdepq %rsi, %rdi, %rax # sched: [100:0.25]
319; ZNVER1-NEXT:    addq %rcx, %rax # sched: [1:0.25]
320; ZNVER1-NEXT:    retq # sched: [1:0.50]
321  %1 = load i64, i64 *%a2
322  %2 = tail call i64 @llvm.x86.bmi.pdep.64(i64 %a0, i64 %1)
323  %3 = tail call i64 @llvm.x86.bmi.pdep.64(i64 %a0, i64 %a1)
324  %4 = add i64 %2, %3
325  ret i64 %4
326}
327declare i64 @llvm.x86.bmi.pdep.64(i64, i64)
328
329define i32 @test_pext_i32(i32 %a0, i32 %a1, i32 *%a2) {
330; GENERIC-LABEL: test_pext_i32:
331; GENERIC:       # %bb.0:
332; GENERIC-NEXT:    pextl (%rdx), %edi, %ecx # sched: [6:0.50]
333; GENERIC-NEXT:    pextl %esi, %edi, %eax # sched: [1:0.33]
334; GENERIC-NEXT:    addl %ecx, %eax # sched: [1:0.33]
335; GENERIC-NEXT:    retq # sched: [1:1.00]
336;
337; HASWELL-LABEL: test_pext_i32:
338; HASWELL:       # %bb.0:
339; HASWELL-NEXT:    pextl (%rdx), %edi, %ecx # sched: [8:1.00]
340; HASWELL-NEXT:    pextl %esi, %edi, %eax # sched: [3:1.00]
341; HASWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
342; HASWELL-NEXT:    retq # sched: [7:1.00]
343;
344; BROADWELL-LABEL: test_pext_i32:
345; BROADWELL:       # %bb.0:
346; BROADWELL-NEXT:    pextl (%rdx), %edi, %ecx # sched: [8:1.00]
347; BROADWELL-NEXT:    pextl %esi, %edi, %eax # sched: [3:1.00]
348; BROADWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
349; BROADWELL-NEXT:    retq # sched: [7:1.00]
350;
351; SKYLAKE-LABEL: test_pext_i32:
352; SKYLAKE:       # %bb.0:
353; SKYLAKE-NEXT:    pextl (%rdx), %edi, %ecx # sched: [8:1.00]
354; SKYLAKE-NEXT:    pextl %esi, %edi, %eax # sched: [3:1.00]
355; SKYLAKE-NEXT:    addl %ecx, %eax # sched: [1:0.25]
356; SKYLAKE-NEXT:    retq # sched: [7:1.00]
357;
358; KNL-LABEL: test_pext_i32:
359; KNL:       # %bb.0:
360; KNL-NEXT:    pextl (%rdx), %edi, %ecx # sched: [8:1.00]
361; KNL-NEXT:    pextl %esi, %edi, %eax # sched: [3:1.00]
362; KNL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
363; KNL-NEXT:    retq # sched: [7:1.00]
364;
365; ZNVER1-LABEL: test_pext_i32:
366; ZNVER1:       # %bb.0:
367; ZNVER1-NEXT:    pextl (%rdx), %edi, %ecx # sched: [100:0.25]
368; ZNVER1-NEXT:    pextl %esi, %edi, %eax # sched: [100:0.25]
369; ZNVER1-NEXT:    addl %ecx, %eax # sched: [1:0.25]
370; ZNVER1-NEXT:    retq # sched: [1:0.50]
371  %1 = load i32, i32 *%a2
372  %2 = tail call i32 @llvm.x86.bmi.pext.32(i32 %a0, i32 %1)
373  %3 = tail call i32 @llvm.x86.bmi.pext.32(i32 %a0, i32 %a1)
374  %4 = add i32 %2, %3
375  ret i32 %4
376}
377declare i32 @llvm.x86.bmi.pext.32(i32, i32)
378
379define i64 @test_pext_i64(i64 %a0, i64 %a1, i64 *%a2) {
380; GENERIC-LABEL: test_pext_i64:
381; GENERIC:       # %bb.0:
382; GENERIC-NEXT:    pextq (%rdx), %rdi, %rcx # sched: [6:0.50]
383; GENERIC-NEXT:    pextq %rsi, %rdi, %rax # sched: [1:0.33]
384; GENERIC-NEXT:    addq %rcx, %rax # sched: [1:0.33]
385; GENERIC-NEXT:    retq # sched: [1:1.00]
386;
387; HASWELL-LABEL: test_pext_i64:
388; HASWELL:       # %bb.0:
389; HASWELL-NEXT:    pextq (%rdx), %rdi, %rcx # sched: [8:1.00]
390; HASWELL-NEXT:    pextq %rsi, %rdi, %rax # sched: [3:1.00]
391; HASWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
392; HASWELL-NEXT:    retq # sched: [7:1.00]
393;
394; BROADWELL-LABEL: test_pext_i64:
395; BROADWELL:       # %bb.0:
396; BROADWELL-NEXT:    pextq (%rdx), %rdi, %rcx # sched: [8:1.00]
397; BROADWELL-NEXT:    pextq %rsi, %rdi, %rax # sched: [3:1.00]
398; BROADWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
399; BROADWELL-NEXT:    retq # sched: [7:1.00]
400;
401; SKYLAKE-LABEL: test_pext_i64:
402; SKYLAKE:       # %bb.0:
403; SKYLAKE-NEXT:    pextq (%rdx), %rdi, %rcx # sched: [8:1.00]
404; SKYLAKE-NEXT:    pextq %rsi, %rdi, %rax # sched: [3:1.00]
405; SKYLAKE-NEXT:    addq %rcx, %rax # sched: [1:0.25]
406; SKYLAKE-NEXT:    retq # sched: [7:1.00]
407;
408; KNL-LABEL: test_pext_i64:
409; KNL:       # %bb.0:
410; KNL-NEXT:    pextq (%rdx), %rdi, %rcx # sched: [8:1.00]
411; KNL-NEXT:    pextq %rsi, %rdi, %rax # sched: [3:1.00]
412; KNL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
413; KNL-NEXT:    retq # sched: [7:1.00]
414;
415; ZNVER1-LABEL: test_pext_i64:
416; ZNVER1:       # %bb.0:
417; ZNVER1-NEXT:    pextq (%rdx), %rdi, %rcx # sched: [100:0.25]
418; ZNVER1-NEXT:    pextq %rsi, %rdi, %rax # sched: [100:0.25]
419; ZNVER1-NEXT:    addq %rcx, %rax # sched: [1:0.25]
420; ZNVER1-NEXT:    retq # sched: [1:0.50]
421  %1 = load i64, i64 *%a2
422  %2 = tail call i64 @llvm.x86.bmi.pext.64(i64 %a0, i64 %1)
423  %3 = tail call i64 @llvm.x86.bmi.pext.64(i64 %a0, i64 %a1)
424  %4 = add i64 %2, %3
425  ret i64 %4
426}
427declare i64 @llvm.x86.bmi.pext.64(i64, i64)
428
429define i32 @test_rorx_i32(i32 %a0, i32 %a1, i32 *%a2) {
430; GENERIC-LABEL: test_rorx_i32:
431; GENERIC:       # %bb.0:
432; GENERIC-NEXT:    rorxl $5, %edi, %ecx # sched: [1:0.50]
433; GENERIC-NEXT:    rorxl $5, (%rdx), %eax # sched: [6:0.50]
434; GENERIC-NEXT:    addl %ecx, %eax # sched: [1:0.33]
435; GENERIC-NEXT:    retq # sched: [1:1.00]
436;
437; HASWELL-LABEL: test_rorx_i32:
438; HASWELL:       # %bb.0:
439; HASWELL-NEXT:    rorxl $5, %edi, %ecx # sched: [1:0.50]
440; HASWELL-NEXT:    rorxl $5, (%rdx), %eax # sched: [6:0.50]
441; HASWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
442; HASWELL-NEXT:    retq # sched: [7:1.00]
443;
444; BROADWELL-LABEL: test_rorx_i32:
445; BROADWELL:       # %bb.0:
446; BROADWELL-NEXT:    rorxl $5, %edi, %ecx # sched: [1:0.50]
447; BROADWELL-NEXT:    rorxl $5, (%rdx), %eax # sched: [6:0.50]
448; BROADWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
449; BROADWELL-NEXT:    retq # sched: [7:1.00]
450;
451; SKYLAKE-LABEL: test_rorx_i32:
452; SKYLAKE:       # %bb.0:
453; SKYLAKE-NEXT:    rorxl $5, %edi, %ecx # sched: [1:0.50]
454; SKYLAKE-NEXT:    rorxl $5, (%rdx), %eax # sched: [6:0.50]
455; SKYLAKE-NEXT:    addl %ecx, %eax # sched: [1:0.25]
456; SKYLAKE-NEXT:    retq # sched: [7:1.00]
457;
458; KNL-LABEL: test_rorx_i32:
459; KNL:       # %bb.0:
460; KNL-NEXT:    rorxl $5, %edi, %ecx # sched: [1:0.50]
461; KNL-NEXT:    rorxl $5, (%rdx), %eax # sched: [6:0.50]
462; KNL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
463; KNL-NEXT:    retq # sched: [7:1.00]
464;
465; ZNVER1-LABEL: test_rorx_i32:
466; ZNVER1:       # %bb.0:
467; ZNVER1-NEXT:    rorxl $5, (%rdx), %eax # sched: [5:0.50]
468; ZNVER1-NEXT:    rorxl $5, %edi, %ecx # sched: [1:0.25]
469; ZNVER1-NEXT:    addl %ecx, %eax # sched: [1:0.25]
470; ZNVER1-NEXT:    retq # sched: [1:0.50]
471  %1 = load i32, i32 *%a2
472  %2 = lshr i32 %a0, 5
473  %3 = shl i32 %a0, 27
474  %4 = or i32 %2, %3
475  %5 = lshr i32 %1, 5
476  %6 = shl i32 %1, 27
477  %7 = or i32 %5, %6
478  %8 = add i32 %4, %7
479  ret i32 %8
480}
481
482define i64 @test_rorx_i64(i64 %a0, i64 %a1, i64 *%a2) {
483; GENERIC-LABEL: test_rorx_i64:
484; GENERIC:       # %bb.0:
485; GENERIC-NEXT:    rorxq $5, %rdi, %rcx # sched: [1:0.50]
486; GENERIC-NEXT:    rorxq $5, (%rdx), %rax # sched: [6:0.50]
487; GENERIC-NEXT:    addq %rcx, %rax # sched: [1:0.33]
488; GENERIC-NEXT:    retq # sched: [1:1.00]
489;
490; HASWELL-LABEL: test_rorx_i64:
491; HASWELL:       # %bb.0:
492; HASWELL-NEXT:    rorxq $5, %rdi, %rcx # sched: [1:0.50]
493; HASWELL-NEXT:    rorxq $5, (%rdx), %rax # sched: [6:0.50]
494; HASWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
495; HASWELL-NEXT:    retq # sched: [7:1.00]
496;
497; BROADWELL-LABEL: test_rorx_i64:
498; BROADWELL:       # %bb.0:
499; BROADWELL-NEXT:    rorxq $5, %rdi, %rcx # sched: [1:0.50]
500; BROADWELL-NEXT:    rorxq $5, (%rdx), %rax # sched: [6:0.50]
501; BROADWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
502; BROADWELL-NEXT:    retq # sched: [7:1.00]
503;
504; SKYLAKE-LABEL: test_rorx_i64:
505; SKYLAKE:       # %bb.0:
506; SKYLAKE-NEXT:    rorxq $5, %rdi, %rcx # sched: [1:0.50]
507; SKYLAKE-NEXT:    rorxq $5, (%rdx), %rax # sched: [6:0.50]
508; SKYLAKE-NEXT:    addq %rcx, %rax # sched: [1:0.25]
509; SKYLAKE-NEXT:    retq # sched: [7:1.00]
510;
511; KNL-LABEL: test_rorx_i64:
512; KNL:       # %bb.0:
513; KNL-NEXT:    rorxq $5, %rdi, %rcx # sched: [1:0.50]
514; KNL-NEXT:    rorxq $5, (%rdx), %rax # sched: [6:0.50]
515; KNL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
516; KNL-NEXT:    retq # sched: [7:1.00]
517;
518; ZNVER1-LABEL: test_rorx_i64:
519; ZNVER1:       # %bb.0:
520; ZNVER1-NEXT:    rorxq $5, (%rdx), %rax # sched: [5:0.50]
521; ZNVER1-NEXT:    rorxq $5, %rdi, %rcx # sched: [1:0.25]
522; ZNVER1-NEXT:    addq %rcx, %rax # sched: [1:0.25]
523; ZNVER1-NEXT:    retq # sched: [1:0.50]
524  %1 = load i64, i64 *%a2
525  %2 = lshr i64 %a0, 5
526  %3 = shl i64 %a0, 59
527  %4 = or i64 %2, %3
528  %5 = lshr i64 %1, 5
529  %6 = shl i64 %1, 59
530  %7 = or i64 %5, %6
531  %8 = add i64 %4, %7
532  ret i64 %8
533}
534
535define i32 @test_sarx_i32(i32 %a0, i32 %a1, i32 *%a2) {
536; GENERIC-LABEL: test_sarx_i32:
537; GENERIC:       # %bb.0:
538; GENERIC-NEXT:    sarxl %esi, %edi, %ecx # sched: [1:0.50]
539; GENERIC-NEXT:    sarxl %esi, (%rdx), %eax # sched: [6:0.50]
540; GENERIC-NEXT:    addl %ecx, %eax # sched: [1:0.33]
541; GENERIC-NEXT:    retq # sched: [1:1.00]
542;
543; HASWELL-LABEL: test_sarx_i32:
544; HASWELL:       # %bb.0:
545; HASWELL-NEXT:    sarxl %esi, %edi, %ecx # sched: [1:0.50]
546; HASWELL-NEXT:    sarxl %esi, (%rdx), %eax # sched: [6:0.50]
547; HASWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
548; HASWELL-NEXT:    retq # sched: [7:1.00]
549;
550; BROADWELL-LABEL: test_sarx_i32:
551; BROADWELL:       # %bb.0:
552; BROADWELL-NEXT:    sarxl %esi, %edi, %ecx # sched: [1:0.50]
553; BROADWELL-NEXT:    sarxl %esi, (%rdx), %eax # sched: [6:0.50]
554; BROADWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
555; BROADWELL-NEXT:    retq # sched: [7:1.00]
556;
557; SKYLAKE-LABEL: test_sarx_i32:
558; SKYLAKE:       # %bb.0:
559; SKYLAKE-NEXT:    sarxl %esi, %edi, %ecx # sched: [1:0.50]
560; SKYLAKE-NEXT:    sarxl %esi, (%rdx), %eax # sched: [6:0.50]
561; SKYLAKE-NEXT:    addl %ecx, %eax # sched: [1:0.25]
562; SKYLAKE-NEXT:    retq # sched: [7:1.00]
563;
564; KNL-LABEL: test_sarx_i32:
565; KNL:       # %bb.0:
566; KNL-NEXT:    sarxl %esi, %edi, %ecx # sched: [1:0.50]
567; KNL-NEXT:    sarxl %esi, (%rdx), %eax # sched: [6:0.50]
568; KNL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
569; KNL-NEXT:    retq # sched: [7:1.00]
570;
571; ZNVER1-LABEL: test_sarx_i32:
572; ZNVER1:       # %bb.0:
573; ZNVER1-NEXT:    sarxl %esi, (%rdx), %eax # sched: [5:0.50]
574; ZNVER1-NEXT:    sarxl %esi, %edi, %ecx # sched: [1:0.25]
575; ZNVER1-NEXT:    addl %ecx, %eax # sched: [1:0.25]
576; ZNVER1-NEXT:    retq # sched: [1:0.50]
577  %1 = load i32, i32 *%a2
578  %2 = ashr i32 %a0, %a1
579  %3 = ashr i32 %1, %a1
580  %4 = add i32 %2, %3
581  ret i32 %4
582}
583
584define i64 @test_sarx_i64(i64 %a0, i64 %a1, i64 *%a2) {
585; GENERIC-LABEL: test_sarx_i64:
586; GENERIC:       # %bb.0:
587; GENERIC-NEXT:    sarxq %rsi, %rdi, %rcx # sched: [1:0.50]
588; GENERIC-NEXT:    sarxq %rsi, (%rdx), %rax # sched: [6:0.50]
589; GENERIC-NEXT:    addq %rcx, %rax # sched: [1:0.33]
590; GENERIC-NEXT:    retq # sched: [1:1.00]
591;
592; HASWELL-LABEL: test_sarx_i64:
593; HASWELL:       # %bb.0:
594; HASWELL-NEXT:    sarxq %rsi, %rdi, %rcx # sched: [1:0.50]
595; HASWELL-NEXT:    sarxq %rsi, (%rdx), %rax # sched: [6:0.50]
596; HASWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
597; HASWELL-NEXT:    retq # sched: [7:1.00]
598;
599; BROADWELL-LABEL: test_sarx_i64:
600; BROADWELL:       # %bb.0:
601; BROADWELL-NEXT:    sarxq %rsi, %rdi, %rcx # sched: [1:0.50]
602; BROADWELL-NEXT:    sarxq %rsi, (%rdx), %rax # sched: [6:0.50]
603; BROADWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
604; BROADWELL-NEXT:    retq # sched: [7:1.00]
605;
606; SKYLAKE-LABEL: test_sarx_i64:
607; SKYLAKE:       # %bb.0:
608; SKYLAKE-NEXT:    sarxq %rsi, %rdi, %rcx # sched: [1:0.50]
609; SKYLAKE-NEXT:    sarxq %rsi, (%rdx), %rax # sched: [6:0.50]
610; SKYLAKE-NEXT:    addq %rcx, %rax # sched: [1:0.25]
611; SKYLAKE-NEXT:    retq # sched: [7:1.00]
612;
613; KNL-LABEL: test_sarx_i64:
614; KNL:       # %bb.0:
615; KNL-NEXT:    sarxq %rsi, %rdi, %rcx # sched: [1:0.50]
616; KNL-NEXT:    sarxq %rsi, (%rdx), %rax # sched: [6:0.50]
617; KNL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
618; KNL-NEXT:    retq # sched: [7:1.00]
619;
620; ZNVER1-LABEL: test_sarx_i64:
621; ZNVER1:       # %bb.0:
622; ZNVER1-NEXT:    sarxq %rsi, (%rdx), %rax # sched: [5:0.50]
623; ZNVER1-NEXT:    sarxq %rsi, %rdi, %rcx # sched: [1:0.25]
624; ZNVER1-NEXT:    addq %rcx, %rax # sched: [1:0.25]
625; ZNVER1-NEXT:    retq # sched: [1:0.50]
626  %1 = load i64, i64 *%a2
627  %2 = ashr i64 %a0, %a1
628  %3 = ashr i64 %1, %a1
629  %4 = add i64 %2, %3
630  ret i64 %4
631}
632
633define i32 @test_shlx_i32(i32 %a0, i32 %a1, i32 *%a2) {
634; GENERIC-LABEL: test_shlx_i32:
635; GENERIC:       # %bb.0:
636; GENERIC-NEXT:    shlxl %esi, %edi, %ecx # sched: [1:0.50]
637; GENERIC-NEXT:    shlxl %esi, (%rdx), %eax # sched: [6:0.50]
638; GENERIC-NEXT:    addl %ecx, %eax # sched: [1:0.33]
639; GENERIC-NEXT:    retq # sched: [1:1.00]
640;
641; HASWELL-LABEL: test_shlx_i32:
642; HASWELL:       # %bb.0:
643; HASWELL-NEXT:    shlxl %esi, %edi, %ecx # sched: [1:0.50]
644; HASWELL-NEXT:    shlxl %esi, (%rdx), %eax # sched: [6:0.50]
645; HASWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
646; HASWELL-NEXT:    retq # sched: [7:1.00]
647;
648; BROADWELL-LABEL: test_shlx_i32:
649; BROADWELL:       # %bb.0:
650; BROADWELL-NEXT:    shlxl %esi, %edi, %ecx # sched: [1:0.50]
651; BROADWELL-NEXT:    shlxl %esi, (%rdx), %eax # sched: [6:0.50]
652; BROADWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
653; BROADWELL-NEXT:    retq # sched: [7:1.00]
654;
655; SKYLAKE-LABEL: test_shlx_i32:
656; SKYLAKE:       # %bb.0:
657; SKYLAKE-NEXT:    shlxl %esi, %edi, %ecx # sched: [1:0.50]
658; SKYLAKE-NEXT:    shlxl %esi, (%rdx), %eax # sched: [6:0.50]
659; SKYLAKE-NEXT:    addl %ecx, %eax # sched: [1:0.25]
660; SKYLAKE-NEXT:    retq # sched: [7:1.00]
661;
662; KNL-LABEL: test_shlx_i32:
663; KNL:       # %bb.0:
664; KNL-NEXT:    shlxl %esi, %edi, %ecx # sched: [1:0.50]
665; KNL-NEXT:    shlxl %esi, (%rdx), %eax # sched: [6:0.50]
666; KNL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
667; KNL-NEXT:    retq # sched: [7:1.00]
668;
669; ZNVER1-LABEL: test_shlx_i32:
670; ZNVER1:       # %bb.0:
671; ZNVER1-NEXT:    shlxl %esi, (%rdx), %eax # sched: [5:0.50]
672; ZNVER1-NEXT:    shlxl %esi, %edi, %ecx # sched: [1:0.25]
673; ZNVER1-NEXT:    addl %ecx, %eax # sched: [1:0.25]
674; ZNVER1-NEXT:    retq # sched: [1:0.50]
675  %1 = load i32, i32 *%a2
676  %2 = shl i32 %a0, %a1
677  %3 = shl i32 %1, %a1
678  %4 = add i32 %2, %3
679  ret i32 %4
680}
681
682define i64 @test_shlx_i64(i64 %a0, i64 %a1, i64 *%a2) {
683; GENERIC-LABEL: test_shlx_i64:
684; GENERIC:       # %bb.0:
685; GENERIC-NEXT:    shlxq %rsi, %rdi, %rcx # sched: [1:0.50]
686; GENERIC-NEXT:    shlxq %rsi, (%rdx), %rax # sched: [6:0.50]
687; GENERIC-NEXT:    addq %rcx, %rax # sched: [1:0.33]
688; GENERIC-NEXT:    retq # sched: [1:1.00]
689;
690; HASWELL-LABEL: test_shlx_i64:
691; HASWELL:       # %bb.0:
692; HASWELL-NEXT:    shlxq %rsi, %rdi, %rcx # sched: [1:0.50]
693; HASWELL-NEXT:    shlxq %rsi, (%rdx), %rax # sched: [6:0.50]
694; HASWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
695; HASWELL-NEXT:    retq # sched: [7:1.00]
696;
697; BROADWELL-LABEL: test_shlx_i64:
698; BROADWELL:       # %bb.0:
699; BROADWELL-NEXT:    shlxq %rsi, %rdi, %rcx # sched: [1:0.50]
700; BROADWELL-NEXT:    shlxq %rsi, (%rdx), %rax # sched: [6:0.50]
701; BROADWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
702; BROADWELL-NEXT:    retq # sched: [7:1.00]
703;
704; SKYLAKE-LABEL: test_shlx_i64:
705; SKYLAKE:       # %bb.0:
706; SKYLAKE-NEXT:    shlxq %rsi, %rdi, %rcx # sched: [1:0.50]
707; SKYLAKE-NEXT:    shlxq %rsi, (%rdx), %rax # sched: [6:0.50]
708; SKYLAKE-NEXT:    addq %rcx, %rax # sched: [1:0.25]
709; SKYLAKE-NEXT:    retq # sched: [7:1.00]
710;
711; KNL-LABEL: test_shlx_i64:
712; KNL:       # %bb.0:
713; KNL-NEXT:    shlxq %rsi, %rdi, %rcx # sched: [1:0.50]
714; KNL-NEXT:    shlxq %rsi, (%rdx), %rax # sched: [6:0.50]
715; KNL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
716; KNL-NEXT:    retq # sched: [7:1.00]
717;
718; ZNVER1-LABEL: test_shlx_i64:
719; ZNVER1:       # %bb.0:
720; ZNVER1-NEXT:    shlxq %rsi, (%rdx), %rax # sched: [5:0.50]
721; ZNVER1-NEXT:    shlxq %rsi, %rdi, %rcx # sched: [1:0.25]
722; ZNVER1-NEXT:    addq %rcx, %rax # sched: [1:0.25]
723; ZNVER1-NEXT:    retq # sched: [1:0.50]
724  %1 = load i64, i64 *%a2
725  %2 = shl i64 %a0, %a1
726  %3 = shl i64 %1, %a1
727  %4 = add i64 %2, %3
728  ret i64 %4
729}
730
731define i32 @test_shrx_i32(i32 %a0, i32 %a1, i32 *%a2) {
732; GENERIC-LABEL: test_shrx_i32:
733; GENERIC:       # %bb.0:
734; GENERIC-NEXT:    shrxl %esi, %edi, %ecx # sched: [1:0.50]
735; GENERIC-NEXT:    shrxl %esi, (%rdx), %eax # sched: [6:0.50]
736; GENERIC-NEXT:    addl %ecx, %eax # sched: [1:0.33]
737; GENERIC-NEXT:    retq # sched: [1:1.00]
738;
739; HASWELL-LABEL: test_shrx_i32:
740; HASWELL:       # %bb.0:
741; HASWELL-NEXT:    shrxl %esi, %edi, %ecx # sched: [1:0.50]
742; HASWELL-NEXT:    shrxl %esi, (%rdx), %eax # sched: [6:0.50]
743; HASWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
744; HASWELL-NEXT:    retq # sched: [7:1.00]
745;
746; BROADWELL-LABEL: test_shrx_i32:
747; BROADWELL:       # %bb.0:
748; BROADWELL-NEXT:    shrxl %esi, %edi, %ecx # sched: [1:0.50]
749; BROADWELL-NEXT:    shrxl %esi, (%rdx), %eax # sched: [6:0.50]
750; BROADWELL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
751; BROADWELL-NEXT:    retq # sched: [7:1.00]
752;
753; SKYLAKE-LABEL: test_shrx_i32:
754; SKYLAKE:       # %bb.0:
755; SKYLAKE-NEXT:    shrxl %esi, %edi, %ecx # sched: [1:0.50]
756; SKYLAKE-NEXT:    shrxl %esi, (%rdx), %eax # sched: [6:0.50]
757; SKYLAKE-NEXT:    addl %ecx, %eax # sched: [1:0.25]
758; SKYLAKE-NEXT:    retq # sched: [7:1.00]
759;
760; KNL-LABEL: test_shrx_i32:
761; KNL:       # %bb.0:
762; KNL-NEXT:    shrxl %esi, %edi, %ecx # sched: [1:0.50]
763; KNL-NEXT:    shrxl %esi, (%rdx), %eax # sched: [6:0.50]
764; KNL-NEXT:    addl %ecx, %eax # sched: [1:0.25]
765; KNL-NEXT:    retq # sched: [7:1.00]
766;
767; ZNVER1-LABEL: test_shrx_i32:
768; ZNVER1:       # %bb.0:
769; ZNVER1-NEXT:    shrxl %esi, (%rdx), %eax # sched: [5:0.50]
770; ZNVER1-NEXT:    shrxl %esi, %edi, %ecx # sched: [1:0.25]
771; ZNVER1-NEXT:    addl %ecx, %eax # sched: [1:0.25]
772; ZNVER1-NEXT:    retq # sched: [1:0.50]
773  %1 = load i32, i32 *%a2
774  %2 = lshr i32 %a0, %a1
775  %3 = lshr i32 %1, %a1
776  %4 = add i32 %2, %3
777  ret i32 %4
778}
779
780define i64 @test_shrx_i64(i64 %a0, i64 %a1, i64 *%a2) {
781; GENERIC-LABEL: test_shrx_i64:
782; GENERIC:       # %bb.0:
783; GENERIC-NEXT:    shrxq %rsi, %rdi, %rcx # sched: [1:0.50]
784; GENERIC-NEXT:    shrxq %rsi, (%rdx), %rax # sched: [6:0.50]
785; GENERIC-NEXT:    addq %rcx, %rax # sched: [1:0.33]
786; GENERIC-NEXT:    retq # sched: [1:1.00]
787;
788; HASWELL-LABEL: test_shrx_i64:
789; HASWELL:       # %bb.0:
790; HASWELL-NEXT:    shrxq %rsi, %rdi, %rcx # sched: [1:0.50]
791; HASWELL-NEXT:    shrxq %rsi, (%rdx), %rax # sched: [6:0.50]
792; HASWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
793; HASWELL-NEXT:    retq # sched: [7:1.00]
794;
795; BROADWELL-LABEL: test_shrx_i64:
796; BROADWELL:       # %bb.0:
797; BROADWELL-NEXT:    shrxq %rsi, %rdi, %rcx # sched: [1:0.50]
798; BROADWELL-NEXT:    shrxq %rsi, (%rdx), %rax # sched: [6:0.50]
799; BROADWELL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
800; BROADWELL-NEXT:    retq # sched: [7:1.00]
801;
802; SKYLAKE-LABEL: test_shrx_i64:
803; SKYLAKE:       # %bb.0:
804; SKYLAKE-NEXT:    shrxq %rsi, %rdi, %rcx # sched: [1:0.50]
805; SKYLAKE-NEXT:    shrxq %rsi, (%rdx), %rax # sched: [6:0.50]
806; SKYLAKE-NEXT:    addq %rcx, %rax # sched: [1:0.25]
807; SKYLAKE-NEXT:    retq # sched: [7:1.00]
808;
809; KNL-LABEL: test_shrx_i64:
810; KNL:       # %bb.0:
811; KNL-NEXT:    shrxq %rsi, %rdi, %rcx # sched: [1:0.50]
812; KNL-NEXT:    shrxq %rsi, (%rdx), %rax # sched: [6:0.50]
813; KNL-NEXT:    addq %rcx, %rax # sched: [1:0.25]
814; KNL-NEXT:    retq # sched: [7:1.00]
815;
816; ZNVER1-LABEL: test_shrx_i64:
817; ZNVER1:       # %bb.0:
818; ZNVER1-NEXT:    shrxq %rsi, (%rdx), %rax # sched: [5:0.50]
819; ZNVER1-NEXT:    shrxq %rsi, %rdi, %rcx # sched: [1:0.25]
820; ZNVER1-NEXT:    addq %rcx, %rax # sched: [1:0.25]
821; ZNVER1-NEXT:    retq # sched: [1:0.50]
822  %1 = load i64, i64 *%a2
823  %2 = lshr i64 %a0, %a1
824  %3 = lshr i64 %1, %a1
825  %4 = add i64 %2, %3
826  ret i64 %4
827}
828