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 ;; Exercise the 'icmp' LLVM IR: https://llvm.org/docs/LangRef.html#icmp-instruction
7 define i1 @icmp_eq(i32 signext %a, i32 signext %b) {
10 ; LA32-NEXT: xor $a0, $a0, $a1
11 ; LA32-NEXT: sltui $a0, $a0, 1
14 ; LA64-LABEL: icmp_eq:
16 ; LA64-NEXT: xor $a0, $a0, $a1
17 ; LA64-NEXT: sltui $a0, $a0, 1
19 %res = icmp eq i32 %a, %b
23 define i1 @icmp_ne(i32 signext %a, i32 signext %b) {
24 ; LA32-LABEL: icmp_ne:
26 ; LA32-NEXT: xor $a0, $a0, $a1
27 ; LA32-NEXT: sltu $a0, $zero, $a0
30 ; LA64-LABEL: icmp_ne:
32 ; LA64-NEXT: xor $a0, $a0, $a1
33 ; LA64-NEXT: sltu $a0, $zero, $a0
35 %res = icmp ne i32 %a, %b
39 define i1 @icmp_ugt(i32 signext %a, i32 signext %b) {
40 ; LA32-LABEL: icmp_ugt:
42 ; LA32-NEXT: sltu $a0, $a1, $a0
45 ; LA64-LABEL: icmp_ugt:
47 ; LA64-NEXT: sltu $a0, $a1, $a0
49 %res = icmp ugt i32 %a, %b
53 define i1 @icmp_uge(i32 signext %a, i32 signext %b) {
54 ; LA32-LABEL: icmp_uge:
56 ; LA32-NEXT: sltu $a0, $a0, $a1
57 ; LA32-NEXT: xori $a0, $a0, 1
60 ; LA64-LABEL: icmp_uge:
62 ; LA64-NEXT: sltu $a0, $a0, $a1
63 ; LA64-NEXT: xori $a0, $a0, 1
65 %res = icmp uge i32 %a, %b
69 define i1 @icmp_ult(i32 signext %a, i32 signext %b) {
70 ; LA32-LABEL: icmp_ult:
72 ; LA32-NEXT: sltu $a0, $a0, $a1
75 ; LA64-LABEL: icmp_ult:
77 ; LA64-NEXT: sltu $a0, $a0, $a1
79 %res = icmp ult i32 %a, %b
83 define i1 @icmp_ule(i32 signext %a, i32 signext %b) {
84 ; LA32-LABEL: icmp_ule:
86 ; LA32-NEXT: sltu $a0, $a1, $a0
87 ; LA32-NEXT: xori $a0, $a0, 1
90 ; LA64-LABEL: icmp_ule:
92 ; LA64-NEXT: sltu $a0, $a1, $a0
93 ; LA64-NEXT: xori $a0, $a0, 1
95 %res = icmp ule i32 %a, %b
99 define i1 @icmp_sgt(i32 signext %a, i32 signext %b) {
100 ; LA32-LABEL: icmp_sgt:
102 ; LA32-NEXT: slt $a0, $a1, $a0
105 ; LA64-LABEL: icmp_sgt:
107 ; LA64-NEXT: slt $a0, $a1, $a0
109 %res = icmp sgt i32 %a, %b
113 define i1 @icmp_sge(i32 signext %a, i32 signext %b) {
114 ; LA32-LABEL: icmp_sge:
116 ; LA32-NEXT: slt $a0, $a0, $a1
117 ; LA32-NEXT: xori $a0, $a0, 1
120 ; LA64-LABEL: icmp_sge:
122 ; LA64-NEXT: slt $a0, $a0, $a1
123 ; LA64-NEXT: xori $a0, $a0, 1
125 %res = icmp sge i32 %a, %b
129 define i1 @icmp_slt(i32 signext %a, i32 signext %b) {
130 ; LA32-LABEL: icmp_slt:
132 ; LA32-NEXT: slt $a0, $a0, $a1
135 ; LA64-LABEL: icmp_slt:
137 ; LA64-NEXT: slt $a0, $a0, $a1
139 %res = icmp slt i32 %a, %b
143 define i1 @icmp_sle(i32 signext %a, i32 signext %b) {
144 ; LA32-LABEL: icmp_sle:
146 ; LA32-NEXT: slt $a0, $a1, $a0
147 ; LA32-NEXT: xori $a0, $a0, 1
150 ; LA64-LABEL: icmp_sle:
152 ; LA64-NEXT: slt $a0, $a1, $a0
153 ; LA64-NEXT: xori $a0, $a0, 1
155 %res = icmp sle i32 %a, %b
159 define i1 @icmp_slt_3(i32 signext %a) {
160 ; LA32-LABEL: icmp_slt_3:
162 ; LA32-NEXT: slti $a0, $a0, 3
165 ; LA64-LABEL: icmp_slt_3:
167 ; LA64-NEXT: slti $a0, $a0, 3
169 %res = icmp slt i32 %a, 3
173 define i1 @icmp_ult_3(i32 signext %a) {
174 ; LA32-LABEL: icmp_ult_3:
176 ; LA32-NEXT: sltui $a0, $a0, 3
179 ; LA64-LABEL: icmp_ult_3:
181 ; LA64-NEXT: sltui $a0, $a0, 3
183 %res = icmp ult i32 %a, 3
187 define i1 @icmp_eq_0(i32 signext %a) {
188 ; LA32-LABEL: icmp_eq_0:
190 ; LA32-NEXT: sltui $a0, $a0, 1
193 ; LA64-LABEL: icmp_eq_0:
195 ; LA64-NEXT: sltui $a0, $a0, 1
197 %res = icmp eq i32 %a, 0
201 define i1 @icmp_eq_3(i32 signext %a) {
202 ; LA32-LABEL: icmp_eq_3:
204 ; LA32-NEXT: addi.w $a0, $a0, -3
205 ; LA32-NEXT: sltui $a0, $a0, 1
208 ; LA64-LABEL: icmp_eq_3:
210 ; LA64-NEXT: addi.d $a0, $a0, -3
211 ; LA64-NEXT: sltui $a0, $a0, 1
213 %res = icmp eq i32 %a, 3
217 define i1 @icmp_ne_0(i32 signext %a) {
218 ; LA32-LABEL: icmp_ne_0:
220 ; LA32-NEXT: sltu $a0, $zero, $a0
223 ; LA64-LABEL: icmp_ne_0:
225 ; LA64-NEXT: sltu $a0, $zero, $a0
227 %res = icmp ne i32 %a, 0
231 define i1 @icmp_ne_3(i32 signext %a) {
232 ; LA32-LABEL: icmp_ne_3:
234 ; LA32-NEXT: addi.w $a0, $a0, -3
235 ; LA32-NEXT: sltu $a0, $zero, $a0
238 ; LA64-LABEL: icmp_ne_3:
240 ; LA64-NEXT: addi.d $a0, $a0, -3
241 ; LA64-NEXT: sltu $a0, $zero, $a0
243 %res = icmp ne i32 %a, 3