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