1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 -mattr=+d < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s --check-prefix=LA64
5 ;; Test integers selection after integers comparison
7 define i32 @select_eq(i32 signext %a, i32 signext %b, i32 %x, i32 %y) {
8 ; LA32-LABEL: select_eq:
10 ; LA32-NEXT: xor $a0, $a0, $a1
11 ; LA32-NEXT: sltui $a0, $a0, 1
12 ; LA32-NEXT: masknez $a1, $a3, $a0
13 ; LA32-NEXT: maskeqz $a0, $a2, $a0
14 ; LA32-NEXT: or $a0, $a0, $a1
17 ; LA64-LABEL: select_eq:
19 ; LA64-NEXT: xor $a0, $a0, $a1
20 ; LA64-NEXT: sltui $a0, $a0, 1
21 ; LA64-NEXT: masknez $a1, $a3, $a0
22 ; LA64-NEXT: maskeqz $a0, $a2, $a0
23 ; LA64-NEXT: or $a0, $a0, $a1
25 %cond = icmp eq i32 %a, %b
26 %res = select i1 %cond, i32 %x, i32 %y
30 define i32 @select_ne(i32 signext %a, i32 signext %b, i32 %x, i32 %y) {
31 ; LA32-LABEL: select_ne:
33 ; LA32-NEXT: xor $a0, $a0, $a1
34 ; LA32-NEXT: sltu $a0, $zero, $a0
35 ; LA32-NEXT: masknez $a1, $a3, $a0
36 ; LA32-NEXT: maskeqz $a0, $a2, $a0
37 ; LA32-NEXT: or $a0, $a0, $a1
40 ; LA64-LABEL: select_ne:
42 ; LA64-NEXT: xor $a0, $a0, $a1
43 ; LA64-NEXT: sltu $a0, $zero, $a0
44 ; LA64-NEXT: masknez $a1, $a3, $a0
45 ; LA64-NEXT: maskeqz $a0, $a2, $a0
46 ; LA64-NEXT: or $a0, $a0, $a1
48 %cond = icmp ne i32 %a, %b
49 %res = select i1 %cond, i32 %x, i32 %y
53 define i32 @select_ugt(i32 signext %a, i32 signext %b, i32 %x, i32 %y) {
54 ; LA32-LABEL: select_ugt:
56 ; LA32-NEXT: sltu $a0, $a1, $a0
57 ; LA32-NEXT: masknez $a1, $a3, $a0
58 ; LA32-NEXT: maskeqz $a0, $a2, $a0
59 ; LA32-NEXT: or $a0, $a0, $a1
62 ; LA64-LABEL: select_ugt:
64 ; LA64-NEXT: sltu $a0, $a1, $a0
65 ; LA64-NEXT: masknez $a1, $a3, $a0
66 ; LA64-NEXT: maskeqz $a0, $a2, $a0
67 ; LA64-NEXT: or $a0, $a0, $a1
69 %cond = icmp ugt i32 %a, %b
70 %res = select i1 %cond, i32 %x, i32 %y
74 define i32 @select_uge(i32 signext %a, i32 signext %b, i32 %x, i32 %y) {
75 ; LA32-LABEL: select_uge:
77 ; LA32-NEXT: sltu $a0, $a0, $a1
78 ; LA32-NEXT: xori $a0, $a0, 1
79 ; LA32-NEXT: masknez $a1, $a3, $a0
80 ; LA32-NEXT: maskeqz $a0, $a2, $a0
81 ; LA32-NEXT: or $a0, $a0, $a1
84 ; LA64-LABEL: select_uge:
86 ; LA64-NEXT: sltu $a0, $a0, $a1
87 ; LA64-NEXT: xori $a0, $a0, 1
88 ; LA64-NEXT: masknez $a1, $a3, $a0
89 ; LA64-NEXT: maskeqz $a0, $a2, $a0
90 ; LA64-NEXT: or $a0, $a0, $a1
92 %cond = icmp uge i32 %a, %b
93 %res = select i1 %cond, i32 %x, i32 %y
97 define i32 @select_ult(i32 signext %a, i32 signext %b, i32 %x, i32 %y) {
98 ; LA32-LABEL: select_ult:
100 ; LA32-NEXT: sltu $a0, $a0, $a1
101 ; LA32-NEXT: masknez $a1, $a3, $a0
102 ; LA32-NEXT: maskeqz $a0, $a2, $a0
103 ; LA32-NEXT: or $a0, $a0, $a1
106 ; LA64-LABEL: select_ult:
108 ; LA64-NEXT: sltu $a0, $a0, $a1
109 ; LA64-NEXT: masknez $a1, $a3, $a0
110 ; LA64-NEXT: maskeqz $a0, $a2, $a0
111 ; LA64-NEXT: or $a0, $a0, $a1
113 %cond = icmp ult i32 %a, %b
114 %res = select i1 %cond, i32 %x, i32 %y
118 define i32 @select_ule(i32 signext %a, i32 signext %b, i32 %x, i32 %y) {
119 ; LA32-LABEL: select_ule:
121 ; LA32-NEXT: sltu $a0, $a1, $a0
122 ; LA32-NEXT: xori $a0, $a0, 1
123 ; LA32-NEXT: masknez $a1, $a3, $a0
124 ; LA32-NEXT: maskeqz $a0, $a2, $a0
125 ; LA32-NEXT: or $a0, $a0, $a1
128 ; LA64-LABEL: select_ule:
130 ; LA64-NEXT: sltu $a0, $a1, $a0
131 ; LA64-NEXT: xori $a0, $a0, 1
132 ; LA64-NEXT: masknez $a1, $a3, $a0
133 ; LA64-NEXT: maskeqz $a0, $a2, $a0
134 ; LA64-NEXT: or $a0, $a0, $a1
136 %cond = icmp ule i32 %a, %b
137 %res = select i1 %cond, i32 %x, i32 %y
141 define i32 @select_sgt(i32 signext %a, i32 signext %b, i32 %x, i32 %y) {
142 ; LA32-LABEL: select_sgt:
144 ; LA32-NEXT: slt $a0, $a1, $a0
145 ; LA32-NEXT: masknez $a1, $a3, $a0
146 ; LA32-NEXT: maskeqz $a0, $a2, $a0
147 ; LA32-NEXT: or $a0, $a0, $a1
150 ; LA64-LABEL: select_sgt:
152 ; LA64-NEXT: slt $a0, $a1, $a0
153 ; LA64-NEXT: masknez $a1, $a3, $a0
154 ; LA64-NEXT: maskeqz $a0, $a2, $a0
155 ; LA64-NEXT: or $a0, $a0, $a1
157 %cond = icmp sgt i32 %a, %b
158 %res = select i1 %cond, i32 %x, i32 %y
162 define i32 @select_sge(i32 signext %a, i32 signext %b, i32 %x, i32 %y) {
163 ; LA32-LABEL: select_sge:
165 ; LA32-NEXT: slt $a0, $a0, $a1
166 ; LA32-NEXT: xori $a0, $a0, 1
167 ; LA32-NEXT: masknez $a1, $a3, $a0
168 ; LA32-NEXT: maskeqz $a0, $a2, $a0
169 ; LA32-NEXT: or $a0, $a0, $a1
172 ; LA64-LABEL: select_sge:
174 ; LA64-NEXT: slt $a0, $a0, $a1
175 ; LA64-NEXT: xori $a0, $a0, 1
176 ; LA64-NEXT: masknez $a1, $a3, $a0
177 ; LA64-NEXT: maskeqz $a0, $a2, $a0
178 ; LA64-NEXT: or $a0, $a0, $a1
180 %cond = icmp sge i32 %a, %b
181 %res = select i1 %cond, i32 %x, i32 %y
185 define i32 @select_slt(i32 signext %a, i32 signext %b, i32 %x, i32 %y) {
186 ; LA32-LABEL: select_slt:
188 ; LA32-NEXT: slt $a0, $a0, $a1
189 ; LA32-NEXT: masknez $a1, $a3, $a0
190 ; LA32-NEXT: maskeqz $a0, $a2, $a0
191 ; LA32-NEXT: or $a0, $a0, $a1
194 ; LA64-LABEL: select_slt:
196 ; LA64-NEXT: slt $a0, $a0, $a1
197 ; LA64-NEXT: masknez $a1, $a3, $a0
198 ; LA64-NEXT: maskeqz $a0, $a2, $a0
199 ; LA64-NEXT: or $a0, $a0, $a1
201 %cond = icmp slt i32 %a, %b
202 %res = select i1 %cond, i32 %x, i32 %y
206 define i32 @select_sle(i32 signext %a, i32 signext %b, i32 %x, i32 %y) {
207 ; LA32-LABEL: select_sle:
209 ; LA32-NEXT: slt $a0, $a1, $a0
210 ; LA32-NEXT: xori $a0, $a0, 1
211 ; LA32-NEXT: masknez $a1, $a3, $a0
212 ; LA32-NEXT: maskeqz $a0, $a2, $a0
213 ; LA32-NEXT: or $a0, $a0, $a1
216 ; LA64-LABEL: select_sle:
218 ; LA64-NEXT: slt $a0, $a1, $a0
219 ; LA64-NEXT: xori $a0, $a0, 1
220 ; LA64-NEXT: masknez $a1, $a3, $a0
221 ; LA64-NEXT: maskeqz $a0, $a2, $a0
222 ; LA64-NEXT: or $a0, $a0, $a1
224 %cond = icmp sle i32 %a, %b
225 %res = select i1 %cond, i32 %x, i32 %y