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 @scmp.8.8(i8 signext %x, i8 signext %y) nounwind {
6 ; RV32I-LABEL: scmp.8.8:
8 ; RV32I-NEXT: slt a2, a0, a1
9 ; RV32I-NEXT: slt a0, a1, a0
10 ; RV32I-NEXT: sub a0, a0, a2
13 ; RV64I-LABEL: scmp.8.8:
15 ; RV64I-NEXT: slt a2, a0, a1
16 ; RV64I-NEXT: slt a0, a1, a0
17 ; RV64I-NEXT: sub a0, a0, a2
19 %1 = call i8 @llvm.scmp(i8 %x, i8 %y)
23 define i8 @scmp.8.16(i16 signext %x, i16 signext %y) nounwind {
24 ; RV32I-LABEL: scmp.8.16:
26 ; RV32I-NEXT: slt a2, a0, a1
27 ; RV32I-NEXT: slt a0, a1, a0
28 ; RV32I-NEXT: sub a0, a0, a2
31 ; RV64I-LABEL: scmp.8.16:
33 ; RV64I-NEXT: slt a2, a0, a1
34 ; RV64I-NEXT: slt a0, a1, a0
35 ; RV64I-NEXT: sub a0, a0, a2
37 %1 = call i8 @llvm.scmp(i16 %x, i16 %y)
41 define i8 @scmp.8.32(i32 %x, i32 %y) nounwind {
42 ; RV32I-LABEL: scmp.8.32:
44 ; RV32I-NEXT: slt a2, a0, a1
45 ; RV32I-NEXT: slt a0, a1, a0
46 ; RV32I-NEXT: sub a0, a0, a2
49 ; RV64I-LABEL: scmp.8.32:
51 ; RV64I-NEXT: sext.w a1, a1
52 ; RV64I-NEXT: sext.w a0, a0
53 ; RV64I-NEXT: slt a2, a0, a1
54 ; RV64I-NEXT: slt a0, a1, a0
55 ; RV64I-NEXT: sub a0, a0, a2
57 %1 = call i8 @llvm.scmp(i32 %x, i32 %y)
61 define i8 @scmp.8.64(i64 %x, i64 %y) nounwind {
62 ; RV32I-LABEL: scmp.8.64:
64 ; RV32I-NEXT: beq a1, a3, .LBB3_2
65 ; RV32I-NEXT: # %bb.1:
66 ; RV32I-NEXT: slt a4, a1, a3
67 ; RV32I-NEXT: slt 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: scmp.8.64:
78 ; RV64I-NEXT: slt a2, a0, a1
79 ; RV64I-NEXT: slt a0, a1, a0
80 ; RV64I-NEXT: sub a0, a0, a2
82 %1 = call i8 @llvm.scmp(i64 %x, i64 %y)
86 define i8 @scmp.8.128(i128 %x, i128 %y) nounwind {
87 ; RV32I-LABEL: scmp.8.128:
89 ; RV32I-NEXT: lw a2, 4(a1)
90 ; RV32I-NEXT: lw a3, 4(a0)
91 ; RV32I-NEXT: lw a4, 8(a1)
92 ; RV32I-NEXT: lw a5, 12(a1)
93 ; RV32I-NEXT: lw a6, 12(a0)
94 ; RV32I-NEXT: lw a7, 8(a0)
95 ; RV32I-NEXT: beq a6, a5, .LBB4_2
96 ; RV32I-NEXT: # %bb.1:
97 ; RV32I-NEXT: slt 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: slt 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: scmp.8.128:
140 ; RV64I-NEXT: beq a1, a3, .LBB4_2
141 ; RV64I-NEXT: # %bb.1:
142 ; RV64I-NEXT: slt a4, a1, a3
143 ; RV64I-NEXT: slt 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.scmp(i128 %x, i128 %y)
155 define i32 @scmp.32.32(i32 %x, i32 %y) nounwind {
156 ; RV32I-LABEL: scmp.32.32:
158 ; RV32I-NEXT: slt a2, a0, a1
159 ; RV32I-NEXT: slt a0, a1, a0
160 ; RV32I-NEXT: sub a0, a0, a2
163 ; RV64I-LABEL: scmp.32.32:
165 ; RV64I-NEXT: sext.w a1, a1
166 ; RV64I-NEXT: sext.w a0, a0
167 ; RV64I-NEXT: slt a2, a0, a1
168 ; RV64I-NEXT: slt a0, a1, a0
169 ; RV64I-NEXT: sub a0, a0, a2
171 %1 = call i32 @llvm.scmp(i32 %x, i32 %y)
175 define i32 @scmp.32.64(i64 %x, i64 %y) nounwind {
176 ; RV32I-LABEL: scmp.32.64:
178 ; RV32I-NEXT: beq a1, a3, .LBB6_2
179 ; RV32I-NEXT: # %bb.1:
180 ; RV32I-NEXT: slt a4, a1, a3
181 ; RV32I-NEXT: slt a0, a3, a1
182 ; RV32I-NEXT: sub a0, a0, a4
184 ; RV32I-NEXT: .LBB6_2:
185 ; RV32I-NEXT: sltu a4, a0, a2
186 ; RV32I-NEXT: sltu a0, a2, a0
187 ; RV32I-NEXT: sub a0, a0, a4
190 ; RV64I-LABEL: scmp.32.64:
192 ; RV64I-NEXT: slt a2, a0, a1
193 ; RV64I-NEXT: slt a0, a1, a0
194 ; RV64I-NEXT: sub a0, a0, a2
196 %1 = call i32 @llvm.scmp(i64 %x, i64 %y)
200 define i64 @scmp.64.64(i64 %x, i64 %y) nounwind {
201 ; RV32I-LABEL: scmp.64.64:
203 ; RV32I-NEXT: beq a1, a3, .LBB7_2
204 ; RV32I-NEXT: # %bb.1:
205 ; RV32I-NEXT: slt a4, a1, a3
206 ; RV32I-NEXT: slt a0, a3, a1
207 ; RV32I-NEXT: j .LBB7_3
208 ; RV32I-NEXT: .LBB7_2:
209 ; RV32I-NEXT: sltu a4, a0, a2
210 ; RV32I-NEXT: sltu a0, a2, a0
211 ; RV32I-NEXT: .LBB7_3:
212 ; RV32I-NEXT: sub a0, a0, a4
213 ; RV32I-NEXT: srai a1, a0, 31
216 ; RV64I-LABEL: scmp.64.64:
218 ; RV64I-NEXT: slt a2, a0, a1
219 ; RV64I-NEXT: slt a0, a1, a0
220 ; RV64I-NEXT: sub a0, a0, a2
222 %1 = call i64 @llvm.scmp(i64 %x, i64 %y)