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 | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 11 | ; RV32I-NEXT: xor a0, a0, a1 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 12 | ; RV32I-NEXT: seqz a0, a0 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 13 | ; RV32I-NEXT: ret |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 14 | %1 = icmp eq i32 %a, %b |
| 15 | %2 = zext i1 %1 to i32 |
| 16 | ret i32 %2 |
| 17 | } |
| 18 | |
Alex Bradbury | 1cc2d0b | 2018-11-09 14:47:36 +0000 | [diff] [blame] | 19 | define i32 @icmp_eqz(i32 %a) nounwind { |
| 20 | ; RV32I-LABEL: icmp_eqz: |
| 21 | ; RV32I: # %bb.0: |
| 22 | ; RV32I-NEXT: seqz a0, a0 |
| 23 | ; RV32I-NEXT: ret |
| 24 | %1 = icmp eq i32 %a, 0 |
| 25 | %2 = zext i1 %1 to i32 |
| 26 | ret i32 %2 |
| 27 | } |
| 28 | |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 29 | define i32 @icmp_ne(i32 %a, i32 %b) nounwind { |
| 30 | ; RV32I-LABEL: icmp_ne: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 31 | ; RV32I: # %bb.0: |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 32 | ; RV32I-NEXT: xor a0, a0, a1 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 33 | ; RV32I-NEXT: snez a0, a0 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 34 | ; RV32I-NEXT: ret |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 35 | %1 = icmp ne i32 %a, %b |
| 36 | %2 = zext i1 %1 to i32 |
| 37 | ret i32 %2 |
| 38 | } |
| 39 | |
Alex Bradbury | 1cc2d0b | 2018-11-09 14:47:36 +0000 | [diff] [blame] | 40 | define i32 @icmp_nez(i32 %a) nounwind { |
| 41 | ; RV32I-LABEL: icmp_nez: |
| 42 | ; RV32I: # %bb.0: |
| 43 | ; RV32I-NEXT: snez a0, a0 |
| 44 | ; RV32I-NEXT: ret |
| 45 | %1 = icmp ne i32 %a, 0 |
| 46 | %2 = zext i1 %1 to i32 |
| 47 | ret i32 %2 |
| 48 | } |
| 49 | |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 50 | define i32 @icmp_ugt(i32 %a, i32 %b) nounwind { |
| 51 | ; RV32I-LABEL: icmp_ugt: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 52 | ; RV32I: # %bb.0: |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 53 | ; RV32I-NEXT: sltu a0, a1, a0 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 54 | ; RV32I-NEXT: ret |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 55 | %1 = icmp ugt i32 %a, %b |
| 56 | %2 = zext i1 %1 to i32 |
| 57 | ret i32 %2 |
| 58 | } |
| 59 | |
| 60 | define i32 @icmp_uge(i32 %a, i32 %b) nounwind { |
| 61 | ; RV32I-LABEL: icmp_uge: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 62 | ; RV32I: # %bb.0: |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 63 | ; RV32I-NEXT: sltu a0, a0, a1 |
| 64 | ; RV32I-NEXT: xori a0, a0, 1 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 65 | ; RV32I-NEXT: ret |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 66 | %1 = icmp uge i32 %a, %b |
| 67 | %2 = zext i1 %1 to i32 |
| 68 | ret i32 %2 |
| 69 | } |
| 70 | |
| 71 | define i32 @icmp_ult(i32 %a, i32 %b) nounwind { |
| 72 | ; RV32I-LABEL: icmp_ult: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 73 | ; RV32I: # %bb.0: |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 74 | ; RV32I-NEXT: sltu a0, a0, a1 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 75 | ; RV32I-NEXT: ret |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 76 | %1 = icmp ult i32 %a, %b |
| 77 | %2 = zext i1 %1 to i32 |
| 78 | ret i32 %2 |
| 79 | } |
| 80 | |
| 81 | define i32 @icmp_ule(i32 %a, i32 %b) nounwind { |
| 82 | ; RV32I-LABEL: icmp_ule: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 83 | ; RV32I: # %bb.0: |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 84 | ; RV32I-NEXT: sltu a0, a1, a0 |
| 85 | ; RV32I-NEXT: xori a0, a0, 1 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 86 | ; RV32I-NEXT: ret |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 87 | %1 = icmp ule i32 %a, %b |
| 88 | %2 = zext i1 %1 to i32 |
| 89 | ret i32 %2 |
| 90 | } |
| 91 | |
| 92 | define i32 @icmp_sgt(i32 %a, i32 %b) nounwind { |
| 93 | ; RV32I-LABEL: icmp_sgt: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 94 | ; RV32I: # %bb.0: |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 95 | ; RV32I-NEXT: slt a0, a1, a0 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 96 | ; RV32I-NEXT: ret |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 97 | %1 = icmp sgt i32 %a, %b |
| 98 | %2 = zext i1 %1 to i32 |
| 99 | ret i32 %2 |
| 100 | } |
| 101 | |
| 102 | define i32 @icmp_sge(i32 %a, i32 %b) nounwind { |
| 103 | ; RV32I-LABEL: icmp_sge: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 104 | ; RV32I: # %bb.0: |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 105 | ; RV32I-NEXT: slt a0, a0, a1 |
| 106 | ; RV32I-NEXT: xori a0, a0, 1 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 107 | ; RV32I-NEXT: ret |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 108 | %1 = icmp sge i32 %a, %b |
| 109 | %2 = zext i1 %1 to i32 |
| 110 | ret i32 %2 |
| 111 | } |
| 112 | |
| 113 | define i32 @icmp_slt(i32 %a, i32 %b) nounwind { |
| 114 | ; RV32I-LABEL: icmp_slt: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 115 | ; RV32I: # %bb.0: |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 116 | ; RV32I-NEXT: slt a0, a0, a1 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 117 | ; RV32I-NEXT: ret |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 118 | %1 = icmp slt i32 %a, %b |
| 119 | %2 = zext i1 %1 to i32 |
| 120 | ret i32 %2 |
| 121 | } |
| 122 | |
| 123 | define i32 @icmp_sle(i32 %a, i32 %b) nounwind { |
| 124 | ; RV32I-LABEL: icmp_sle: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 125 | ; RV32I: # %bb.0: |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 126 | ; RV32I-NEXT: slt a0, a1, a0 |
| 127 | ; RV32I-NEXT: xori a0, a0, 1 |
Alex Bradbury | 59136ff | 2017-12-15 09:47:01 +0000 | [diff] [blame] | 128 | ; RV32I-NEXT: ret |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame] | 129 | %1 = icmp sle i32 %a, %b |
| 130 | %2 = zext i1 %1 to i32 |
| 131 | ret i32 %2 |
| 132 | } |
| 133 | |
| 134 | ; TODO: check variants with an immediate? |