1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \
3 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s \
4 ; RUN: --check-prefixes=CHECK,CHECK-LE
5 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \
6 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr10 < %s | FileCheck %s \
7 ; RUN: --check-prefixes=CHECK,CHECK-BE
9 ; This file does not contain many test cases involving comparisons and logical
10 ; comparisons (cmplwi, cmpldi). This is because alternative code is generated
11 ; when there is a compare (logical or not), followed by a sign or zero extend.
12 ; This codegen will be re-evaluated at a later time on whether or not it should
15 @globalVal = common dso_local local_unnamed_addr global i8 0, align 1
16 @globalVal2 = common dso_local local_unnamed_addr global i32 0, align 4
17 @globalVal3 = common dso_local local_unnamed_addr global i64 0, align 8
18 @globalVal4 = common dso_local local_unnamed_addr global i16 0, align 2
20 define dso_local signext i32 @setbcr1(i8 %a) {
21 ; CHECK-LABEL: setbcr1:
22 ; CHECK: # %bb.0: # %entry
23 ; CHECK-NEXT: clrlwi r3, r3, 24
24 ; CHECK-NEXT: cmpwi r3, 1
25 ; CHECK-NEXT: setbcr r3, eq
28 %cmp = icmp ne i8 %a, 1
29 %conv = zext i1 %cmp to i32
33 define dso_local signext i32 @setbcr2(i32 %a) {
34 ; CHECK-LABEL: setbcr2:
35 ; CHECK: # %bb.0: # %entry
36 ; CHECK-NEXT: cmpwi r3, 1
37 ; CHECK-NEXT: setbcr r3, eq
40 %cmp = icmp ne i32 %a, 1
41 %conv = zext i1 %cmp to i32
45 define dso_local signext i32 @setbcr3(i64 %a) {
46 ; CHECK-LABEL: setbcr3:
47 ; CHECK: # %bb.0: # %entry
48 ; CHECK-NEXT: cmpdi r3, 1
49 ; CHECK-NEXT: setbcr r3, eq
52 %cmp = icmp ne i64 %a, 1
53 %conv = zext i1 %cmp to i32
57 define dso_local signext i32 @setbcr4(i16 %a) {
58 ; CHECK-LABEL: setbcr4:
59 ; CHECK: # %bb.0: # %entry
60 ; CHECK-NEXT: clrlwi r3, r3, 16
61 ; CHECK-NEXT: cmpwi r3, 1
62 ; CHECK-NEXT: setbcr r3, eq
65 %cmp = icmp ne i16 %a, 1
66 %conv = zext i1 %cmp to i32
70 define signext i64 @setbcr5(i8 %a) {
71 ; CHECK-LABEL: setbcr5:
72 ; CHECK: # %bb.0: # %entry
73 ; CHECK-NEXT: clrlwi r3, r3, 24
74 ; CHECK-NEXT: cmpwi r3, 1
75 ; CHECK-NEXT: setbcr r3, eq
78 %cmp = icmp ne i8 %a, 1
79 %conv = zext i1 %cmp to i64
83 define signext i64 @setbcr6(i32 %a) {
84 ; CHECK-LABEL: setbcr6:
85 ; CHECK: # %bb.0: # %entry
86 ; CHECK-NEXT: cmpwi r3, 1
87 ; CHECK-NEXT: setbcr r3, eq
90 %cmp = icmp ne i32 %a, 1
91 %conv = zext i1 %cmp to i64
95 define signext i64 @setbcr7(i64 %a) {
96 ; CHECK-LABEL: setbcr7:
97 ; CHECK: # %bb.0: # %entry
98 ; CHECK-NEXT: cmpdi r3, 1
99 ; CHECK-NEXT: setbcr r3, eq
102 %cmp = icmp ne i64 %a, 1
103 %conv = zext i1 %cmp to i64
107 define signext i64 @setbcr8(i16 %a) {
108 ; CHECK-LABEL: setbcr8:
109 ; CHECK: # %bb.0: # %entry
110 ; CHECK-NEXT: clrlwi r3, r3, 16
111 ; CHECK-NEXT: cmpwi r3, 1
112 ; CHECK-NEXT: setbcr r3, eq
115 %cmp = icmp ne i16 %a, 1
116 %conv = zext i1 %cmp to i64
120 define dso_local void @setbcr9(i8 %a) {
121 ; CHECK-LE-LABEL: setbcr9:
122 ; CHECK-LE: # %bb.0: # %entry
123 ; CHECK-LE-NEXT: clrlwi r3, r3, 24
124 ; CHECK-LE-NEXT: cmpwi r3, 1
125 ; CHECK-LE-NEXT: setbcr r3, eq
126 ; CHECK-LE-NEXT: pstb r3, globalVal@PCREL(0), 1
129 ; CHECK-BE-LABEL: setbcr9:
130 ; CHECK-BE: # %bb.0: # %entry
131 ; CHECK-BE-NEXT: clrlwi r3, r3, 24
132 ; CHECK-BE-NEXT: addis r4, r2, globalVal@toc@ha
133 ; CHECK-BE-NEXT: cmpwi r3, 1
134 ; CHECK-BE-NEXT: setbcr r3, eq
135 ; CHECK-BE-NEXT: stb r3, globalVal@toc@l(r4)
138 %cmp = icmp ne i8 %a, 1
139 %conv1 = zext i1 %cmp to i8
140 store i8 %conv1, ptr @globalVal, align 1
144 define dso_local void @setbcr10(i32 %a) {
145 ; CHECK-LE-LABEL: setbcr10:
146 ; CHECK-LE: # %bb.0: # %entry
147 ; CHECK-LE-NEXT: cmpwi r3, 1
148 ; CHECK-LE-NEXT: setbcr r3, eq
149 ; CHECK-LE-NEXT: pstw r3, globalVal2@PCREL(0), 1
152 ; CHECK-BE-LABEL: setbcr10:
153 ; CHECK-BE: # %bb.0: # %entry
154 ; CHECK-BE-NEXT: cmpwi r3, 1
155 ; CHECK-BE-NEXT: addis r4, r2, globalVal2@toc@ha
156 ; CHECK-BE-NEXT: setbcr r3, eq
157 ; CHECK-BE-NEXT: stw r3, globalVal2@toc@l(r4)
160 %cmp = icmp ne i32 %a, 1
161 %conv1 = zext i1 %cmp to i32
162 store i32 %conv1, ptr @globalVal2, align 4
166 define dso_local void @setbcr11(i64 %a) {
167 ; CHECK-LE-LABEL: setbcr11:
168 ; CHECK-LE: # %bb.0: # %entry
169 ; CHECK-LE-NEXT: cmpdi r3, 1
170 ; CHECK-LE-NEXT: setbcr r3, eq
171 ; CHECK-LE-NEXT: pstd r3, globalVal3@PCREL(0), 1
174 ; CHECK-BE-LABEL: setbcr11:
175 ; CHECK-BE: # %bb.0: # %entry
176 ; CHECK-BE-NEXT: cmpdi r3, 1
177 ; CHECK-BE-NEXT: addis r4, r2, globalVal3@toc@ha
178 ; CHECK-BE-NEXT: setbcr r3, eq
179 ; CHECK-BE-NEXT: std r3, globalVal3@toc@l(r4)
182 %cmp = icmp ne i64 %a, 1
183 %conv1 = zext i1 %cmp to i64
184 store i64 %conv1, ptr @globalVal3, align 8
188 define dso_local void @setbcr12(i16 %a) {
189 ; CHECK-LE-LABEL: setbcr12:
190 ; CHECK-LE: # %bb.0: # %entry
191 ; CHECK-LE-NEXT: clrlwi r3, r3, 16
192 ; CHECK-LE-NEXT: cmpwi r3, 1
193 ; CHECK-LE-NEXT: setbcr r3, eq
194 ; CHECK-LE-NEXT: psth r3, globalVal4@PCREL(0), 1
197 ; CHECK-BE-LABEL: setbcr12:
198 ; CHECK-BE: # %bb.0: # %entry
199 ; CHECK-BE-NEXT: clrlwi r3, r3, 16
200 ; CHECK-BE-NEXT: addis r4, r2, globalVal4@toc@ha
201 ; CHECK-BE-NEXT: cmpwi r3, 1
202 ; CHECK-BE-NEXT: setbcr r3, eq
203 ; CHECK-BE-NEXT: sth r3, globalVal4@toc@l(r4)
206 %cmp = icmp ne i16 %a, 1
207 %conv1 = zext i1 %cmp to i16
208 store i16 %conv1, ptr @globalVal4, align 2