• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=i386-unknown-unknown -mcpu=core-avx2 < %s | FileCheck --check-prefix=BMI2 %s
2; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=core-avx2 < %s | FileCheck --check-prefix=BMI264 %s
3
4define i32 @shl32(i32 %x, i32 %shamt) nounwind uwtable readnone {
5entry:
6  %shl = shl i32 %x, %shamt
7; BMI2: shl32
8; BMI2: shlxl
9; BMI2: ret
10; BMI264: shl32
11; BMI264: shlxl
12; BMI264: ret
13  ret i32 %shl
14}
15
16define i32 @shl32i(i32 %x) nounwind uwtable readnone {
17entry:
18  %shl = shl i32 %x, 5
19; BMI2: shl32i
20; BMI2-NOT: shlxl
21; BMI2: ret
22; BMI264: shl32i
23; BMI264-NOT: shlxl
24; BMI264: ret
25  ret i32 %shl
26}
27
28define i32 @shl32p(i32* %p, i32 %shamt) nounwind uwtable readnone {
29entry:
30  %x = load i32, i32* %p
31  %shl = shl i32 %x, %shamt
32; BMI2: shl32p
33; BMI2: shlxl %{{.+}}, ({{.+}}), %{{.+}}
34; BMI2: ret
35; BMI264: shl32p
36; BMI264: shlxl %{{.+}}, ({{.+}}), %{{.+}}
37; BMI264: ret
38  ret i32 %shl
39}
40
41define i32 @shl32pi(i32* %p) nounwind uwtable readnone {
42entry:
43  %x = load i32, i32* %p
44  %shl = shl i32 %x, 5
45; BMI2: shl32pi
46; BMI2-NOT: shlxl
47; BMI2: ret
48; BMI264: shl32pi
49; BMI264-NOT: shlxl
50; BMI264: ret
51  ret i32 %shl
52}
53
54define i64 @shl64(i64 %x, i64 %shamt) nounwind uwtable readnone {
55entry:
56  %shl = shl i64 %x, %shamt
57; BMI264: shl64
58; BMI264: shlxq
59; BMI264: ret
60  ret i64 %shl
61}
62
63define i64 @shl64i(i64 %x) nounwind uwtable readnone {
64entry:
65  %shl = shl i64 %x, 7
66; BMI264: shl64i
67; BMI264-NOT: shlxq
68; BMI264: ret
69  ret i64 %shl
70}
71
72define i64 @shl64p(i64* %p, i64 %shamt) nounwind uwtable readnone {
73entry:
74  %x = load i64, i64* %p
75  %shl = shl i64 %x, %shamt
76; BMI264: shl64p
77; BMI264: shlxq %{{.+}}, ({{.+}}), %{{.+}}
78; BMI264: ret
79  ret i64 %shl
80}
81
82define i64 @shl64pi(i64* %p) nounwind uwtable readnone {
83entry:
84  %x = load i64, i64* %p
85  %shl = shl i64 %x, 7
86; BMI264: shl64pi
87; BMI264-NOT: shlxq
88; BMI264: ret
89  ret i64 %shl
90}
91
92define i32 @lshr32(i32 %x, i32 %shamt) nounwind uwtable readnone {
93entry:
94  %shl = lshr i32 %x, %shamt
95; BMI2: lshr32
96; BMI2: shrxl
97; BMI2: ret
98; BMI264: lshr32
99; BMI264: shrxl
100; BMI264: ret
101  ret i32 %shl
102}
103
104define i32 @lshr32p(i32* %p, i32 %shamt) nounwind uwtable readnone {
105entry:
106  %x = load i32, i32* %p
107  %shl = lshr i32 %x, %shamt
108; BMI2: lshr32p
109; BMI2: shrxl %{{.+}}, ({{.+}}), %{{.+}}
110; BMI2: ret
111; BMI264: lshr32p
112; BMI264: shrxl %{{.+}}, ({{.+}}), %{{.+}}
113; BMI264: ret
114  ret i32 %shl
115}
116
117define i64 @lshr64(i64 %x, i64 %shamt) nounwind uwtable readnone {
118entry:
119  %shl = lshr i64 %x, %shamt
120; BMI264: lshr64
121; BMI264: shrxq
122; BMI264: ret
123  ret i64 %shl
124}
125
126define i64 @lshr64p(i64* %p, i64 %shamt) nounwind uwtable readnone {
127entry:
128  %x = load i64, i64* %p
129  %shl = lshr i64 %x, %shamt
130; BMI264: lshr64p
131; BMI264: shrxq %{{.+}}, ({{.+}}), %{{.+}}
132; BMI264: ret
133  ret i64 %shl
134}
135
136define i32 @ashr32(i32 %x, i32 %shamt) nounwind uwtable readnone {
137entry:
138  %shl = ashr i32 %x, %shamt
139; BMI2: ashr32
140; BMI2: sarxl
141; BMI2: ret
142; BMI264: ashr32
143; BMI264: sarxl
144; BMI264: ret
145  ret i32 %shl
146}
147
148define i32 @ashr32p(i32* %p, i32 %shamt) nounwind uwtable readnone {
149entry:
150  %x = load i32, i32* %p
151  %shl = ashr i32 %x, %shamt
152; BMI2: ashr32p
153; Source order scheduling prevents folding, rdar:14208996.
154; BMI2: sarxl %{{.+}}, ({{.+}}), %{{.+}}
155; BMI2: ret
156; BMI264: ashr32p
157; BMI264: sarxl %{{.+}}, ({{.+}}), %{{.+}}
158; BMI264: ret
159  ret i32 %shl
160}
161
162define i64 @ashr64(i64 %x, i64 %shamt) nounwind uwtable readnone {
163entry:
164  %shl = ashr i64 %x, %shamt
165; BMI264: ashr64
166; BMI264: sarxq
167; BMI264: ret
168  ret i64 %shl
169}
170
171define i64 @ashr64p(i64* %p, i64 %shamt) nounwind uwtable readnone {
172entry:
173  %x = load i64, i64* %p
174  %shl = ashr i64 %x, %shamt
175; BMI264: ashr64p
176; BMI264: sarxq %{{.+}}, ({{.+}}), %{{.+}}
177; BMI264: ret
178  ret i64 %shl
179}
180