• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
3; RUN:   -ppc-gpr-icmps=all -ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-BE \
4; RUN:  --implicit-check-not cmpw --implicit-check-not cmpd --implicit-check-not cmpl
5; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
6; RUN:   -ppc-gpr-icmps=all -ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-LE \
7; RUN:  --implicit-check-not cmpw --implicit-check-not cmpd --implicit-check-not cmpl
8
9@glob = local_unnamed_addr global i32 0, align 4
10
11define signext i32 @test_inesi(i32 signext %a, i32 signext %b) {
12; CHECK-LABEL: test_inesi:
13; CHECK:       # %bb.0: # %entry
14; CHECK-NEXT:    xor r3, r3, r4
15; CHECK-NEXT:    cntlzw r3, r3
16; CHECK-NEXT:    srwi r3, r3, 5
17; CHECK-NEXT:    xori r3, r3, 1
18; CHECK-NEXT:    blr
19; CHECK-BE-LABEL: test_inesi:
20; CHECK-BE:       # %bb.0: # %entry
21; CHECK-BE-NEXT:    xor r3, r3, r4
22; CHECK-BE-NEXT:    cntlzw r3, r3
23; CHECK-BE-NEXT:    srwi r3, r3, 5
24; CHECK-BE-NEXT:    xori r3, r3, 1
25; CHECK-BE-NEXT:    blr
26;
27; CHECK-LE-LABEL: test_inesi:
28; CHECK-LE:       # %bb.0: # %entry
29; CHECK-LE-NEXT:    xor r3, r3, r4
30; CHECK-LE-NEXT:    cntlzw r3, r3
31; CHECK-LE-NEXT:    srwi r3, r3, 5
32; CHECK-LE-NEXT:    xori r3, r3, 1
33; CHECK-LE-NEXT:    blr
34entry:
35  %cmp = icmp ne i32 %a, %b
36  %conv = zext i1 %cmp to i32
37  ret i32 %conv
38}
39
40define signext i32 @test_inesi_sext(i32 signext %a, i32 signext %b) {
41; CHECK-LABEL: test_inesi_sext:
42; CHECK:       # %bb.0: # %entry
43; CHECK-NEXT:    xor r3, r3, r4
44; CHECK-NEXT:    cntlzw r3, r3
45; CHECK-NEXT:    srwi r3, r3, 5
46; CHECK-NEXT:    xori r3, r3, 1
47; CHECK-NEXT:    neg r3, r3
48; CHECK-NEXT:    blr
49; CHECK-BE-LABEL: test_inesi_sext:
50; CHECK-BE:       # %bb.0: # %entry
51; CHECK-BE-NEXT:    xor r3, r3, r4
52; CHECK-BE-NEXT:    cntlzw r3, r3
53; CHECK-BE-NEXT:    srwi r3, r3, 5
54; CHECK-BE-NEXT:    xori r3, r3, 1
55; CHECK-BE-NEXT:    neg r3, r3
56; CHECK-BE-NEXT:    blr
57;
58; CHECK-LE-LABEL: test_inesi_sext:
59; CHECK-LE:       # %bb.0: # %entry
60; CHECK-LE-NEXT:    xor r3, r3, r4
61; CHECK-LE-NEXT:    cntlzw r3, r3
62; CHECK-LE-NEXT:    srwi r3, r3, 5
63; CHECK-LE-NEXT:    xori r3, r3, 1
64; CHECK-LE-NEXT:    neg r3, r3
65; CHECK-LE-NEXT:    blr
66entry:
67  %cmp = icmp ne i32 %a, %b
68  %sub = sext i1 %cmp to i32
69  ret i32 %sub
70}
71
72define signext i32 @test_inesi_z(i32 signext %a) {
73; CHECK-LABEL: test_inesi_z:
74; CHECK:       # %bb.0: # %entry
75; CHECK-NEXT:    cntlzw r3, r3
76; CHECK-NEXT:    srwi r3, r3, 5
77; CHECK-NEXT:    xori r3, r3, 1
78; CHECK-NEXT:    blr
79; CHECK-BE-LABEL: test_inesi_z:
80; CHECK-BE:       # %bb.0: # %entry
81; CHECK-BE-NEXT:    cntlzw r3, r3
82; CHECK-BE-NEXT:    srwi r3, r3, 5
83; CHECK-BE-NEXT:    xori r3, r3, 1
84; CHECK-BE-NEXT:    blr
85;
86; CHECK-LE-LABEL: test_inesi_z:
87; CHECK-LE:       # %bb.0: # %entry
88; CHECK-LE-NEXT:    cntlzw r3, r3
89; CHECK-LE-NEXT:    srwi r3, r3, 5
90; CHECK-LE-NEXT:    xori r3, r3, 1
91; CHECK-LE-NEXT:    blr
92entry:
93  %cmp = icmp ne i32 %a, 0
94  %conv = zext i1 %cmp to i32
95  ret i32 %conv
96}
97
98define signext i32 @test_inesi_sext_z(i32 signext %a) {
99; CHECK-LABEL: test_inesi_sext_z:
100; CHECK:       # %bb.0: # %entry
101; CHECK-NEXT:    cntlzw r3, r3
102; CHECK-NEXT:    srwi r3, r3, 5
103; CHECK-NEXT:    xori r3, r3, 1
104; CHECK-NEXT:    neg r3, r3
105; CHECK-NEXT:    blr
106; CHECK-BE-LABEL: test_inesi_sext_z:
107; CHECK-BE:       # %bb.0: # %entry
108; CHECK-BE-NEXT:    cntlzw r3, r3
109; CHECK-BE-NEXT:    srwi r3, r3, 5
110; CHECK-BE-NEXT:    xori r3, r3, 1
111; CHECK-BE-NEXT:    neg r3, r3
112; CHECK-BE-NEXT:    blr
113;
114; CHECK-LE-LABEL: test_inesi_sext_z:
115; CHECK-LE:       # %bb.0: # %entry
116; CHECK-LE-NEXT:    cntlzw r3, r3
117; CHECK-LE-NEXT:    srwi r3, r3, 5
118; CHECK-LE-NEXT:    xori r3, r3, 1
119; CHECK-LE-NEXT:    neg r3, r3
120; CHECK-LE-NEXT:    blr
121entry:
122  %cmp = icmp ne i32 %a, 0
123  %sub = sext i1 %cmp to i32
124  ret i32 %sub
125}
126
127define void @test_inesi_store(i32 signext %a, i32 signext %b) {
128; CHECK-LABEL: test_inesi_store:
129; CHECK:       # %bb.0: # %entry
130; CHECK-NEXT:    xor r3, r3, r4
131; CHECK-NEXT:    addis r5, r2, glob@toc@ha
132; CHECK-NEXT:    cntlzw r3, r3
133; CHECK-NEXT:    srwi r3, r3, 5
134; CHECK-NEXT:    xori r3, r3, 1
135; CHECK-NEXT:    stw r3, glob@toc@l(r5)
136; CHECK-NEXT:    blr
137; CHECK-BE-LABEL: test_inesi_store:
138; CHECK-BE:       # %bb.0: # %entry
139; CHECK-BE-NEXT:    addis r5, r2, .LC0@toc@ha
140; CHECK-BE-NEXT:    xor r3, r3, r4
141; CHECK-BE-NEXT:    cntlzw r3, r3
142; CHECK-BE-NEXT:    ld r4, .LC0@toc@l(r5)
143; CHECK-BE-NEXT:    srwi r3, r3, 5
144; CHECK-BE-NEXT:    xori r3, r3, 1
145; CHECK-BE-NEXT:    stw r3, 0(r4)
146; CHECK-BE-NEXT:    blr
147;
148; CHECK-LE-LABEL: test_inesi_store:
149; CHECK-LE:       # %bb.0: # %entry
150; CHECK-LE-NEXT:    xor r3, r3, r4
151; CHECK-LE-NEXT:    addis r5, r2, glob@toc@ha
152; CHECK-LE-NEXT:    cntlzw r3, r3
153; CHECK-LE-NEXT:    srwi r3, r3, 5
154; CHECK-LE-NEXT:    xori r3, r3, 1
155; CHECK-LE-NEXT:    stw r3, glob@toc@l(r5)
156; CHECK-LE-NEXT:    blr
157entry:
158  %cmp = icmp ne i32 %a, %b
159  %conv = zext i1 %cmp to i32
160  store i32 %conv, i32* @glob, align 4
161  ret void
162}
163
164define void @test_inesi_sext_store(i32 signext %a, i32 signext %b) {
165; CHECK-LABEL: test_inesi_sext_store:
166; CHECK:       # %bb.0: # %entry
167; CHECK-NEXT:    xor r3, r3, r4
168; CHECK-NEXT:    addis r5, r2, glob@toc@ha
169; CHECK-NEXT:    cntlzw r3, r3
170; CHECK-NEXT:    srwi r3, r3, 5
171; CHECK-NEXT:    xori r3, r3, 1
172; CHECK-NEXT:    neg r3, r3
173; CHECK-NEXT:    stw r3, glob@toc@l(r5)
174; CHECK-NEXT:    blr
175; CHECK-BE-LABEL: test_inesi_sext_store:
176; CHECK-BE:       # %bb.0: # %entry
177; CHECK-BE-NEXT:    xor r3, r3, r4
178; CHECK-BE-NEXT:    addis r5, r2, .LC0@toc@ha
179; CHECK-BE-NEXT:    cntlzw r3, r3
180; CHECK-BE-NEXT:    ld r4, .LC0@toc@l(r5)
181; CHECK-BE-NEXT:    srwi r3, r3, 5
182; CHECK-BE-NEXT:    xori r3, r3, 1
183; CHECK-BE-NEXT:    neg r3, r3
184; CHECK-BE-NEXT:    stw r3, 0(r4)
185; CHECK-BE-NEXT:    blr
186;
187; CHECK-LE-LABEL: test_inesi_sext_store:
188; CHECK-LE:       # %bb.0: # %entry
189; CHECK-LE-NEXT:    xor r3, r3, r4
190; CHECK-LE-NEXT:    addis r5, r2, glob@toc@ha
191; CHECK-LE-NEXT:    cntlzw r3, r3
192; CHECK-LE-NEXT:    srwi r3, r3, 5
193; CHECK-LE-NEXT:    xori r3, r3, 1
194; CHECK-LE-NEXT:    neg r3, r3
195; CHECK-LE-NEXT:    stw r3, glob@toc@l(r5)
196; CHECK-LE-NEXT:    blr
197entry:
198  %cmp = icmp ne i32 %a, %b
199  %sub = sext i1 %cmp to i32
200  store i32 %sub, i32* @glob, align 4
201  ret void
202}
203
204define void @test_inesi_z_store(i32 signext %a) {
205; CHECK-LABEL: test_inesi_z_store:
206; CHECK:       # %bb.0: # %entry
207; CHECK-NEXT:    cntlzw r3, r3
208; CHECK-NEXT:    addis r4, r2, glob@toc@ha
209; CHECK-NEXT:    srwi r3, r3, 5
210; CHECK-NEXT:    xori r3, r3, 1
211; CHECK-NEXT:    stw r3, glob@toc@l(r4)
212; CHECK-NEXT:    blr
213; CHECK-BE-LABEL: test_inesi_z_store:
214; CHECK-BE:       # %bb.0: # %entry
215; CHECK-BE-NEXT:    addis r4, r2, .LC0@toc@ha
216; CHECK-BE-NEXT:    cntlzw r3, r3
217; CHECK-BE-NEXT:    ld r4, .LC0@toc@l(r4)
218; CHECK-BE-NEXT:    srwi r3, r3, 5
219; CHECK-BE-NEXT:    xori r3, r3, 1
220; CHECK-BE-NEXT:    stw r3, 0(r4)
221; CHECK-BE-NEXT:    blr
222;
223; CHECK-LE-LABEL: test_inesi_z_store:
224; CHECK-LE:       # %bb.0: # %entry
225; CHECK-LE-NEXT:    cntlzw r3, r3
226; CHECK-LE-NEXT:    addis r4, r2, glob@toc@ha
227; CHECK-LE-NEXT:    srwi r3, r3, 5
228; CHECK-LE-NEXT:    xori r3, r3, 1
229; CHECK-LE-NEXT:    stw r3, glob@toc@l(r4)
230; CHECK-LE-NEXT:    blr
231entry:
232  %cmp = icmp ne i32 %a, 0
233  %conv = zext i1 %cmp to i32
234  store i32 %conv, i32* @glob, align 4
235  ret void
236}
237
238define void @test_inesi_sext_z_store(i32 signext %a) {
239; CHECK-LABEL: test_inesi_sext_z_store:
240; CHECK:       # %bb.0: # %entry
241; CHECK-NEXT:    cntlzw r3, r3
242; CHECK-NEXT:    addis r4, r2, glob@toc@ha
243; CHECK-NEXT:    srwi r3, r3, 5
244; CHECK-NEXT:    xori r3, r3, 1
245; CHECK-NEXT:    neg r3, r3
246; CHECK-NEXT:    stw r3, glob@toc@l(r4)
247; CHECK-NEXT:    blr
248; CHECK-BE-LABEL: test_inesi_sext_z_store:
249; CHECK-BE:       # %bb.0: # %entry
250; CHECK-BE-NEXT:    addis r4, r2, .LC0@toc@ha
251; CHECK-BE-NEXT:    cntlzw r3, r3
252; CHECK-BE-NEXT:    srwi r3, r3, 5
253; CHECK-BE-NEXT:    ld r4, .LC0@toc@l(r4)
254; CHECK-BE-NEXT:    xori r3, r3, 1
255; CHECK-BE-NEXT:    neg r3, r3
256; CHECK-BE-NEXT:    stw r3, 0(r4)
257; CHECK-BE-NEXT:    blr
258;
259; CHECK-LE-LABEL: test_inesi_sext_z_store:
260; CHECK-LE:       # %bb.0: # %entry
261; CHECK-LE-NEXT:    cntlzw r3, r3
262; CHECK-LE-NEXT:    addis r4, r2, glob@toc@ha
263; CHECK-LE-NEXT:    srwi r3, r3, 5
264; CHECK-LE-NEXT:    xori r3, r3, 1
265; CHECK-LE-NEXT:    neg r3, r3
266; CHECK-LE-NEXT:    stw r3, glob@toc@l(r4)
267; CHECK-LE-NEXT:    blr
268entry:
269  %cmp = icmp ne i32 %a, 0
270  %sub = sext i1 %cmp to i32
271  store i32 %sub, i32* @glob, align 4
272  ret void
273}
274