1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc < %s -mtriple=riscv32 | FileCheck %s --check-prefix=RV32I
3 ; RUN: llc < %s -mtriple=riscv64 | FileCheck %s --check-prefix=RV64I
5 define i8 @ucmp.8.8(i8 zeroext %x, i8 zeroext %y) nounwind {
6 ; RV32I-LABEL: ucmp.8.8:
8 ; RV32I-NEXT: sltu a2, a0, a1
9 ; RV32I-NEXT: sltu a0, a1, a0
10 ; RV32I-NEXT: sub a0, a0, a2
13 ; RV64I-LABEL: ucmp.8.8:
15 ; RV64I-NEXT: sltu a2, a0, a1
16 ; RV64I-NEXT: sltu a0, a1, a0
17 ; RV64I-NEXT: sub a0, a0, a2
19 %1 = call i8 @llvm.ucmp(i8 %x, i8 %y)
23 define i8 @ucmp.8.16(i16 zeroext %x, i16 zeroext %y) nounwind {
24 ; RV32I-LABEL: ucmp.8.16:
26 ; RV32I-NEXT: sltu a2, a0, a1
27 ; RV32I-NEXT: sltu a0, a1, a0
28 ; RV32I-NEXT: sub a0, a0, a2
31 ; RV64I-LABEL: ucmp.8.16:
33 ; RV64I-NEXT: sltu a2, a0, a1
34 ; RV64I-NEXT: sltu a0, a1, a0
35 ; RV64I-NEXT: sub a0, a0, a2
37 %1 = call i8 @llvm.ucmp(i16 %x, i16 %y)
41 define i8 @ucmp.8.32(i32 %x, i32 %y) nounwind {
42 ; RV32I-LABEL: ucmp.8.32:
44 ; RV32I-NEXT: sltu a2, a0, a1
45 ; RV32I-NEXT: sltu a0, a1, a0
46 ; RV32I-NEXT: sub a0, a0, a2
49 ; RV64I-LABEL: ucmp.8.32:
51 ; RV64I-NEXT: sext.w a1, a1
52 ; RV64I-NEXT: sext.w a0, a0
53 ; RV64I-NEXT: sltu a2, a0, a1
54 ; RV64I-NEXT: sltu a0, a1, a0
55 ; RV64I-NEXT: sub a0, a0, a2
57 %1 = call i8 @llvm.ucmp(i32 %x, i32 %y)
61 define i8 @ucmp.8.64(i64 %x, i64 %y) nounwind {
62 ; RV32I-LABEL: ucmp.8.64:
64 ; RV32I-NEXT: beq a1, a3, .LBB3_2
65 ; RV32I-NEXT: # %bb.1:
66 ; RV32I-NEXT: sltu a4, a1, a3
67 ; RV32I-NEXT: sltu a0, a3, a1
68 ; RV32I-NEXT: sub a0, a0, a4
70 ; RV32I-NEXT: .LBB3_2:
71 ; RV32I-NEXT: sltu a4, a0, a2
72 ; RV32I-NEXT: sltu a0, a2, a0
73 ; RV32I-NEXT: sub a0, a0, a4
76 ; RV64I-LABEL: ucmp.8.64:
78 ; RV64I-NEXT: sltu a2, a0, a1
79 ; RV64I-NEXT: sltu a0, a1, a0
80 ; RV64I-NEXT: sub a0, a0, a2
82 %1 = call i8 @llvm.ucmp(i64 %x, i64 %y)
86 define i8 @ucmp.8.128(i128 %x, i128 %y) nounwind {
87 ; RV32I-LABEL: ucmp.8.128:
89 ; RV32I-NEXT: lw a2, 4(a1)
90 ; RV32I-NEXT: lw a4, 8(a1)
91 ; RV32I-NEXT: lw a5, 12(a1)
92 ; RV32I-NEXT: lw a6, 12(a0)
93 ; RV32I-NEXT: lw a3, 4(a0)
94 ; RV32I-NEXT: lw a7, 8(a0)
95 ; RV32I-NEXT: beq a6, a5, .LBB4_2
96 ; RV32I-NEXT: # %bb.1:
97 ; RV32I-NEXT: sltu t2, a6, a5
98 ; RV32I-NEXT: j .LBB4_3
99 ; RV32I-NEXT: .LBB4_2:
100 ; RV32I-NEXT: sltu t2, a7, a4
101 ; RV32I-NEXT: .LBB4_3:
102 ; RV32I-NEXT: lw a1, 0(a1)
103 ; RV32I-NEXT: lw t0, 0(a0)
104 ; RV32I-NEXT: beq a3, a2, .LBB4_5
105 ; RV32I-NEXT: # %bb.4:
106 ; RV32I-NEXT: sltu a0, a3, a2
107 ; RV32I-NEXT: j .LBB4_6
108 ; RV32I-NEXT: .LBB4_5:
109 ; RV32I-NEXT: sltu a0, t0, a1
110 ; RV32I-NEXT: .LBB4_6:
111 ; RV32I-NEXT: xor t1, a6, a5
112 ; RV32I-NEXT: xor t3, a7, a4
113 ; RV32I-NEXT: or t1, t3, t1
114 ; RV32I-NEXT: beqz t1, .LBB4_8
115 ; RV32I-NEXT: # %bb.7:
116 ; RV32I-NEXT: mv a0, t2
117 ; RV32I-NEXT: .LBB4_8:
118 ; RV32I-NEXT: beq a6, a5, .LBB4_11
119 ; RV32I-NEXT: # %bb.9:
120 ; RV32I-NEXT: sltu a4, a5, a6
121 ; RV32I-NEXT: bne a3, a2, .LBB4_12
122 ; RV32I-NEXT: .LBB4_10:
123 ; RV32I-NEXT: sltu a1, a1, t0
124 ; RV32I-NEXT: bnez t1, .LBB4_13
125 ; RV32I-NEXT: j .LBB4_14
126 ; RV32I-NEXT: .LBB4_11:
127 ; RV32I-NEXT: sltu a4, a4, a7
128 ; RV32I-NEXT: beq a3, a2, .LBB4_10
129 ; RV32I-NEXT: .LBB4_12:
130 ; RV32I-NEXT: sltu a1, a2, a3
131 ; RV32I-NEXT: beqz t1, .LBB4_14
132 ; RV32I-NEXT: .LBB4_13:
133 ; RV32I-NEXT: mv a1, a4
134 ; RV32I-NEXT: .LBB4_14:
135 ; RV32I-NEXT: sub a0, a1, a0
138 ; RV64I-LABEL: ucmp.8.128:
140 ; RV64I-NEXT: beq a1, a3, .LBB4_2
141 ; RV64I-NEXT: # %bb.1:
142 ; RV64I-NEXT: sltu a4, a1, a3
143 ; RV64I-NEXT: sltu a0, a3, a1
144 ; RV64I-NEXT: sub a0, a0, a4
146 ; RV64I-NEXT: .LBB4_2:
147 ; RV64I-NEXT: sltu a4, a0, a2
148 ; RV64I-NEXT: sltu a0, a2, a0
149 ; RV64I-NEXT: sub a0, a0, a4
151 %1 = call i8 @llvm.ucmp(i128 %x, i128 %y)
155 define i32 @ucmp.32.32(i32 %x, i32 %y) nounwind {
156 ; RV32I-LABEL: ucmp.32.32:
158 ; RV32I-NEXT: sltu a2, a0, a1
159 ; RV32I-NEXT: sltu a0, a1, a0
160 ; RV32I-NEXT: sub a0, a0, a2
163 ; RV64I-LABEL: ucmp.32.32:
165 ; RV64I-NEXT: sext.w a1, a1
166 ; RV64I-NEXT: sext.w a0, a0
167 ; RV64I-NEXT: sltu a2, a0, a1
168 ; RV64I-NEXT: sltu a0, a1, a0
169 ; RV64I-NEXT: sub a0, a0, a2
171 %1 = call i32 @llvm.ucmp(i32 %x, i32 %y)
175 define i32 @ucmp.32.32_sext(i32 signext %x, i32 signext %y) nounwind {
176 ; RV32I-LABEL: ucmp.32.32_sext:
178 ; RV32I-NEXT: sltu a2, a0, a1
179 ; RV32I-NEXT: sltu a0, a1, a0
180 ; RV32I-NEXT: sub a0, a0, a2
183 ; RV64I-LABEL: ucmp.32.32_sext:
185 ; RV64I-NEXT: sltu a2, a0, a1
186 ; RV64I-NEXT: sltu a0, a1, a0
187 ; RV64I-NEXT: sub a0, a0, a2
189 %1 = call i32 @llvm.ucmp(i32 %x, i32 %y)
193 define i32 @ucmp.32.32_zext(i32 zeroext %x, i32 zeroext %y) nounwind {
194 ; RV32I-LABEL: ucmp.32.32_zext:
196 ; RV32I-NEXT: sltu a2, a0, a1
197 ; RV32I-NEXT: sltu a0, a1, a0
198 ; RV32I-NEXT: sub a0, a0, a2
201 ; RV64I-LABEL: ucmp.32.32_zext:
203 ; RV64I-NEXT: sltu a2, a0, a1
204 ; RV64I-NEXT: sltu a0, a1, a0
205 ; RV64I-NEXT: sub a0, a0, a2
207 %1 = call i32 @llvm.ucmp(i32 %x, i32 %y)
211 define i32 @ucmp.32.64(i64 %x, i64 %y) nounwind {
212 ; RV32I-LABEL: ucmp.32.64:
214 ; RV32I-NEXT: beq a1, a3, .LBB8_2
215 ; RV32I-NEXT: # %bb.1:
216 ; RV32I-NEXT: sltu a4, a1, a3
217 ; RV32I-NEXT: sltu a0, a3, a1
218 ; RV32I-NEXT: sub a0, a0, a4
220 ; RV32I-NEXT: .LBB8_2:
221 ; RV32I-NEXT: sltu a4, a0, a2
222 ; RV32I-NEXT: sltu a0, a2, a0
223 ; RV32I-NEXT: sub a0, a0, a4
226 ; RV64I-LABEL: ucmp.32.64:
228 ; RV64I-NEXT: sltu a2, a0, a1
229 ; RV64I-NEXT: sltu a0, a1, a0
230 ; RV64I-NEXT: sub a0, a0, a2
232 %1 = call i32 @llvm.ucmp(i64 %x, i64 %y)
236 define i64 @ucmp.64.64(i64 %x, i64 %y) nounwind {
237 ; RV32I-LABEL: ucmp.64.64:
239 ; RV32I-NEXT: beq a1, a3, .LBB9_2
240 ; RV32I-NEXT: # %bb.1:
241 ; RV32I-NEXT: sltu a4, a1, a3
242 ; RV32I-NEXT: sltu a0, a3, a1
243 ; RV32I-NEXT: j .LBB9_3
244 ; RV32I-NEXT: .LBB9_2:
245 ; RV32I-NEXT: sltu a4, a0, a2
246 ; RV32I-NEXT: sltu a0, a2, a0
247 ; RV32I-NEXT: .LBB9_3:
248 ; RV32I-NEXT: sub a0, a0, a4
249 ; RV32I-NEXT: srai a1, a0, 31
252 ; RV64I-LABEL: ucmp.64.64:
254 ; RV64I-NEXT: sltu a2, a0, a1
255 ; RV64I-NEXT: sltu a0, a1, a0
256 ; RV64I-NEXT: sub a0, a0, a2
258 %1 = call i64 @llvm.ucmp(i64 %x, i64 %y)