1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV32I
5 ; TODO: check the generated instructions for the equivalent of seqz, snez,
6 ; sltz, sgtz map to something simple
8 define i32 @icmp_eq(i32 %a, i32 %b) nounwind {
9 ; RV32I-LABEL: icmp_eq:
11 ; RV32I-NEXT: xor a0, a0, a1
12 ; RV32I-NEXT: seqz a0, a0
14 %1 = icmp eq i32 %a, %b
15 %2 = zext i1 %1 to i32
19 define i32 @icmp_eq_constant(i32 %a) nounwind {
20 ; RV32I-LABEL: icmp_eq_constant:
22 ; RV32I-NEXT: xori a0, a0, 42
23 ; RV32I-NEXT: seqz a0, a0
25 %1 = icmp eq i32 %a, 42
26 %2 = zext i1 %1 to i32
30 define i32 @icmp_eqz(i32 %a) nounwind {
31 ; RV32I-LABEL: icmp_eqz:
33 ; RV32I-NEXT: seqz a0, a0
35 %1 = icmp eq i32 %a, 0
36 %2 = zext i1 %1 to i32
40 define i32 @icmp_ne(i32 %a, i32 %b) nounwind {
41 ; RV32I-LABEL: icmp_ne:
43 ; RV32I-NEXT: xor a0, a0, a1
44 ; RV32I-NEXT: snez a0, a0
46 %1 = icmp ne i32 %a, %b
47 %2 = zext i1 %1 to i32
51 define i32 @icmp_ne_constant(i32 %a) nounwind {
52 ; RV32I-LABEL: icmp_ne_constant:
54 ; RV32I-NEXT: xori a0, a0, 42
55 ; RV32I-NEXT: snez a0, a0
57 %1 = icmp ne i32 %a, 42
58 %2 = zext i1 %1 to i32
62 define i32 @icmp_nez(i32 %a) nounwind {
63 ; RV32I-LABEL: icmp_nez:
65 ; RV32I-NEXT: snez a0, a0
67 %1 = icmp ne i32 %a, 0
68 %2 = zext i1 %1 to i32
72 define i32 @icmp_ugt(i32 %a, i32 %b) nounwind {
73 ; RV32I-LABEL: icmp_ugt:
75 ; RV32I-NEXT: sltu a0, a1, a0
77 %1 = icmp ugt i32 %a, %b
78 %2 = zext i1 %1 to i32
82 define i32 @icmp_uge(i32 %a, i32 %b) nounwind {
83 ; RV32I-LABEL: icmp_uge:
85 ; RV32I-NEXT: sltu a0, a0, a1
86 ; RV32I-NEXT: xori a0, a0, 1
88 %1 = icmp uge i32 %a, %b
89 %2 = zext i1 %1 to i32
93 define i32 @icmp_ult(i32 %a, i32 %b) nounwind {
94 ; RV32I-LABEL: icmp_ult:
96 ; RV32I-NEXT: sltu a0, a0, a1
98 %1 = icmp ult i32 %a, %b
99 %2 = zext i1 %1 to i32
103 define i32 @icmp_ule(i32 %a, i32 %b) nounwind {
104 ; RV32I-LABEL: icmp_ule:
106 ; RV32I-NEXT: sltu a0, a1, a0
107 ; RV32I-NEXT: xori a0, a0, 1
109 %1 = icmp ule i32 %a, %b
110 %2 = zext i1 %1 to i32
114 define i32 @icmp_sgt(i32 %a, i32 %b) nounwind {
115 ; RV32I-LABEL: icmp_sgt:
117 ; RV32I-NEXT: slt a0, a1, a0
119 %1 = icmp sgt i32 %a, %b
120 %2 = zext i1 %1 to i32
124 define i32 @icmp_sge(i32 %a, i32 %b) nounwind {
125 ; RV32I-LABEL: icmp_sge:
127 ; RV32I-NEXT: slt a0, a0, a1
128 ; RV32I-NEXT: xori a0, a0, 1
130 %1 = icmp sge i32 %a, %b
131 %2 = zext i1 %1 to i32
135 define i32 @icmp_slt(i32 %a, i32 %b) nounwind {
136 ; RV32I-LABEL: icmp_slt:
138 ; RV32I-NEXT: slt a0, a0, a1
140 %1 = icmp slt i32 %a, %b
141 %2 = zext i1 %1 to i32
145 define i32 @icmp_sle(i32 %a, i32 %b) nounwind {
146 ; RV32I-LABEL: icmp_sle:
148 ; RV32I-NEXT: slt a0, a1, a0
149 ; RV32I-NEXT: xori a0, a0, 1
151 %1 = icmp sle i32 %a, %b
152 %2 = zext i1 %1 to i32
156 ; TODO: check variants with an immediate?