| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 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 |
| 4 | |
| 5 | ; TODO: check the generated instructions for the equivalent of seqz, snez, |
| 6 | ; sltz, sgtz map to something simple |
| 7 | |
| 8 | define i32 @icmp_eq(i32 %a, i32 %b) nounwind { |
| 9 | ; RV32I-LABEL: icmp_eq: |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 10 | ; RV32I: # %bb.0: |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 11 | ; RV32I-NEXT: addi sp, sp, -16 |
| 12 | ; RV32I-NEXT: sw ra, 12(sp) |
| 13 | ; RV32I-NEXT: sw s0, 8(sp) |
| 14 | ; RV32I-NEXT: addi s0, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 15 | ; RV32I-NEXT: xor a0, a0, a1 |
| 16 | ; RV32I-NEXT: sltiu a0, a0, 1 |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 17 | ; RV32I-NEXT: lw s0, 8(sp) |
| 18 | ; RV32I-NEXT: lw ra, 12(sp) |
| 19 | ; RV32I-NEXT: addi sp, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 20 | ; RV32I-NEXT: jalr zero, ra, 0 |
| 21 | %1 = icmp eq i32 %a, %b |
| 22 | %2 = zext i1 %1 to i32 |
| 23 | ret i32 %2 |
| 24 | } |
| 25 | |
| 26 | define i32 @icmp_ne(i32 %a, i32 %b) nounwind { |
| 27 | ; RV32I-LABEL: icmp_ne: |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 28 | ; RV32I: # %bb.0: |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 29 | ; RV32I-NEXT: addi sp, sp, -16 |
| 30 | ; RV32I-NEXT: sw ra, 12(sp) |
| 31 | ; RV32I-NEXT: sw s0, 8(sp) |
| 32 | ; RV32I-NEXT: addi s0, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 33 | ; RV32I-NEXT: xor a0, a0, a1 |
| 34 | ; RV32I-NEXT: sltu a0, zero, a0 |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 35 | ; RV32I-NEXT: lw s0, 8(sp) |
| 36 | ; RV32I-NEXT: lw ra, 12(sp) |
| 37 | ; RV32I-NEXT: addi sp, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 38 | ; RV32I-NEXT: jalr zero, ra, 0 |
| 39 | %1 = icmp ne i32 %a, %b |
| 40 | %2 = zext i1 %1 to i32 |
| 41 | ret i32 %2 |
| 42 | } |
| 43 | |
| 44 | define i32 @icmp_ugt(i32 %a, i32 %b) nounwind { |
| 45 | ; RV32I-LABEL: icmp_ugt: |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 46 | ; RV32I: # %bb.0: |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 47 | ; RV32I-NEXT: addi sp, sp, -16 |
| 48 | ; RV32I-NEXT: sw ra, 12(sp) |
| 49 | ; RV32I-NEXT: sw s0, 8(sp) |
| 50 | ; RV32I-NEXT: addi s0, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 51 | ; RV32I-NEXT: sltu a0, a1, a0 |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 52 | ; RV32I-NEXT: lw s0, 8(sp) |
| 53 | ; RV32I-NEXT: lw ra, 12(sp) |
| 54 | ; RV32I-NEXT: addi sp, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 55 | ; RV32I-NEXT: jalr zero, ra, 0 |
| 56 | %1 = icmp ugt i32 %a, %b |
| 57 | %2 = zext i1 %1 to i32 |
| 58 | ret i32 %2 |
| 59 | } |
| 60 | |
| 61 | define i32 @icmp_uge(i32 %a, i32 %b) nounwind { |
| 62 | ; RV32I-LABEL: icmp_uge: |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 63 | ; RV32I: # %bb.0: |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 64 | ; RV32I-NEXT: addi sp, sp, -16 |
| 65 | ; RV32I-NEXT: sw ra, 12(sp) |
| 66 | ; RV32I-NEXT: sw s0, 8(sp) |
| 67 | ; RV32I-NEXT: addi s0, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 68 | ; RV32I-NEXT: sltu a0, a0, a1 |
| 69 | ; RV32I-NEXT: xori a0, a0, 1 |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 70 | ; RV32I-NEXT: lw s0, 8(sp) |
| 71 | ; RV32I-NEXT: lw ra, 12(sp) |
| 72 | ; RV32I-NEXT: addi sp, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 73 | ; RV32I-NEXT: jalr zero, ra, 0 |
| 74 | %1 = icmp uge i32 %a, %b |
| 75 | %2 = zext i1 %1 to i32 |
| 76 | ret i32 %2 |
| 77 | } |
| 78 | |
| 79 | define i32 @icmp_ult(i32 %a, i32 %b) nounwind { |
| 80 | ; RV32I-LABEL: icmp_ult: |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 81 | ; RV32I: # %bb.0: |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 82 | ; RV32I-NEXT: addi sp, sp, -16 |
| 83 | ; RV32I-NEXT: sw ra, 12(sp) |
| 84 | ; RV32I-NEXT: sw s0, 8(sp) |
| 85 | ; RV32I-NEXT: addi s0, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 86 | ; RV32I-NEXT: sltu a0, a0, a1 |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 87 | ; RV32I-NEXT: lw s0, 8(sp) |
| 88 | ; RV32I-NEXT: lw ra, 12(sp) |
| 89 | ; RV32I-NEXT: addi sp, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 90 | ; RV32I-NEXT: jalr zero, ra, 0 |
| 91 | %1 = icmp ult i32 %a, %b |
| 92 | %2 = zext i1 %1 to i32 |
| 93 | ret i32 %2 |
| 94 | } |
| 95 | |
| 96 | define i32 @icmp_ule(i32 %a, i32 %b) nounwind { |
| 97 | ; RV32I-LABEL: icmp_ule: |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 98 | ; RV32I: # %bb.0: |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 99 | ; RV32I-NEXT: addi sp, sp, -16 |
| 100 | ; RV32I-NEXT: sw ra, 12(sp) |
| 101 | ; RV32I-NEXT: sw s0, 8(sp) |
| 102 | ; RV32I-NEXT: addi s0, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 103 | ; RV32I-NEXT: sltu a0, a1, a0 |
| 104 | ; RV32I-NEXT: xori a0, a0, 1 |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 105 | ; RV32I-NEXT: lw s0, 8(sp) |
| 106 | ; RV32I-NEXT: lw ra, 12(sp) |
| 107 | ; RV32I-NEXT: addi sp, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 108 | ; RV32I-NEXT: jalr zero, ra, 0 |
| 109 | %1 = icmp ule i32 %a, %b |
| 110 | %2 = zext i1 %1 to i32 |
| 111 | ret i32 %2 |
| 112 | } |
| 113 | |
| 114 | define i32 @icmp_sgt(i32 %a, i32 %b) nounwind { |
| 115 | ; RV32I-LABEL: icmp_sgt: |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 116 | ; RV32I: # %bb.0: |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 117 | ; RV32I-NEXT: addi sp, sp, -16 |
| 118 | ; RV32I-NEXT: sw ra, 12(sp) |
| 119 | ; RV32I-NEXT: sw s0, 8(sp) |
| 120 | ; RV32I-NEXT: addi s0, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 121 | ; RV32I-NEXT: slt a0, a1, a0 |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 122 | ; RV32I-NEXT: lw s0, 8(sp) |
| 123 | ; RV32I-NEXT: lw ra, 12(sp) |
| 124 | ; RV32I-NEXT: addi sp, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 125 | ; RV32I-NEXT: jalr zero, ra, 0 |
| 126 | %1 = icmp sgt i32 %a, %b |
| 127 | %2 = zext i1 %1 to i32 |
| 128 | ret i32 %2 |
| 129 | } |
| 130 | |
| 131 | define i32 @icmp_sge(i32 %a, i32 %b) nounwind { |
| 132 | ; RV32I-LABEL: icmp_sge: |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 133 | ; RV32I: # %bb.0: |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 134 | ; RV32I-NEXT: addi sp, sp, -16 |
| 135 | ; RV32I-NEXT: sw ra, 12(sp) |
| 136 | ; RV32I-NEXT: sw s0, 8(sp) |
| 137 | ; RV32I-NEXT: addi s0, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 138 | ; RV32I-NEXT: slt a0, a0, a1 |
| 139 | ; RV32I-NEXT: xori a0, a0, 1 |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 140 | ; RV32I-NEXT: lw s0, 8(sp) |
| 141 | ; RV32I-NEXT: lw ra, 12(sp) |
| 142 | ; RV32I-NEXT: addi sp, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 143 | ; RV32I-NEXT: jalr zero, ra, 0 |
| 144 | %1 = icmp sge i32 %a, %b |
| 145 | %2 = zext i1 %1 to i32 |
| 146 | ret i32 %2 |
| 147 | } |
| 148 | |
| 149 | define i32 @icmp_slt(i32 %a, i32 %b) nounwind { |
| 150 | ; RV32I-LABEL: icmp_slt: |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 151 | ; RV32I: # %bb.0: |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 152 | ; RV32I-NEXT: addi sp, sp, -16 |
| 153 | ; RV32I-NEXT: sw ra, 12(sp) |
| 154 | ; RV32I-NEXT: sw s0, 8(sp) |
| 155 | ; RV32I-NEXT: addi s0, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 156 | ; RV32I-NEXT: slt a0, a0, a1 |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 157 | ; RV32I-NEXT: lw s0, 8(sp) |
| 158 | ; RV32I-NEXT: lw ra, 12(sp) |
| 159 | ; RV32I-NEXT: addi sp, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 160 | ; RV32I-NEXT: jalr zero, ra, 0 |
| 161 | %1 = icmp slt i32 %a, %b |
| 162 | %2 = zext i1 %1 to i32 |
| 163 | ret i32 %2 |
| 164 | } |
| 165 | |
| 166 | define i32 @icmp_sle(i32 %a, i32 %b) nounwind { |
| 167 | ; RV32I-LABEL: icmp_sle: |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 168 | ; RV32I: # %bb.0: |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 169 | ; RV32I-NEXT: addi sp, sp, -16 |
| 170 | ; RV32I-NEXT: sw ra, 12(sp) |
| 171 | ; RV32I-NEXT: sw s0, 8(sp) |
| 172 | ; RV32I-NEXT: addi s0, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 173 | ; RV32I-NEXT: slt a0, a1, a0 |
| 174 | ; RV32I-NEXT: xori a0, a0, 1 |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 175 | ; RV32I-NEXT: lw s0, 8(sp) |
| 176 | ; RV32I-NEXT: lw ra, 12(sp) |
| 177 | ; RV32I-NEXT: addi sp, sp, 16 |
| Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 178 | ; RV32I-NEXT: jalr zero, ra, 0 |
| 179 | %1 = icmp sle i32 %a, %b |
| 180 | %2 = zext i1 %1 to i32 |
| 181 | ret i32 %2 |
| 182 | } |
| 183 | |
| 184 | ; TODO: check variants with an immediate? |