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_eqz(i32 %a) nounwind {
20 ; RV32I-LABEL: icmp_eqz:
22 ; RV32I-NEXT: seqz a0, a0
24 %1 = icmp eq i32 %a, 0
25 %2 = zext i1 %1 to i32
29 define i32 @icmp_ne(i32 %a, i32 %b) nounwind {
30 ; RV32I-LABEL: icmp_ne:
32 ; RV32I-NEXT: xor a0, a0, a1
33 ; RV32I-NEXT: snez a0, a0
35 %1 = icmp ne i32 %a, %b
36 %2 = zext i1 %1 to i32
40 define i32 @icmp_nez(i32 %a) nounwind {
41 ; RV32I-LABEL: icmp_nez:
43 ; RV32I-NEXT: snez a0, a0
45 %1 = icmp ne i32 %a, 0
46 %2 = zext i1 %1 to i32
50 define i32 @icmp_ugt(i32 %a, i32 %b) nounwind {
51 ; RV32I-LABEL: icmp_ugt:
53 ; RV32I-NEXT: sltu a0, a1, a0
55 %1 = icmp ugt i32 %a, %b
56 %2 = zext i1 %1 to i32
60 define i32 @icmp_uge(i32 %a, i32 %b) nounwind {
61 ; RV32I-LABEL: icmp_uge:
63 ; RV32I-NEXT: sltu a0, a0, a1
64 ; RV32I-NEXT: xori a0, a0, 1
66 %1 = icmp uge i32 %a, %b
67 %2 = zext i1 %1 to i32
71 define i32 @icmp_ult(i32 %a, i32 %b) nounwind {
72 ; RV32I-LABEL: icmp_ult:
74 ; RV32I-NEXT: sltu a0, a0, a1
76 %1 = icmp ult i32 %a, %b
77 %2 = zext i1 %1 to i32
81 define i32 @icmp_ule(i32 %a, i32 %b) nounwind {
82 ; RV32I-LABEL: icmp_ule:
84 ; RV32I-NEXT: sltu a0, a1, a0
85 ; RV32I-NEXT: xori a0, a0, 1
87 %1 = icmp ule i32 %a, %b
88 %2 = zext i1 %1 to i32
92 define i32 @icmp_sgt(i32 %a, i32 %b) nounwind {
93 ; RV32I-LABEL: icmp_sgt:
95 ; RV32I-NEXT: slt a0, a1, a0
97 %1 = icmp sgt i32 %a, %b
98 %2 = zext i1 %1 to i32
102 define i32 @icmp_sge(i32 %a, i32 %b) nounwind {
103 ; RV32I-LABEL: icmp_sge:
105 ; RV32I-NEXT: slt a0, a0, a1
106 ; RV32I-NEXT: xori a0, a0, 1
108 %1 = icmp sge i32 %a, %b
109 %2 = zext i1 %1 to i32
113 define i32 @icmp_slt(i32 %a, i32 %b) nounwind {
114 ; RV32I-LABEL: icmp_slt:
116 ; RV32I-NEXT: slt a0, a0, a1
118 %1 = icmp slt i32 %a, %b
119 %2 = zext i1 %1 to i32
123 define i32 @icmp_sle(i32 %a, i32 %b) nounwind {
124 ; RV32I-LABEL: icmp_sle:
126 ; RV32I-NEXT: slt a0, a1, a0
127 ; RV32I-NEXT: xori a0, a0, 1
129 %1 = icmp sle i32 %a, %b
130 %2 = zext i1 %1 to i32
134 ; TODO: check variants with an immediate?