Daniel Sanders | 0d97270 | 2016-06-24 12:23:17 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=mips64el -mcpu=mips4 -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,MIPS4,ACCMULDIV %s |
| 2 | ; RUN: llc -march=mips64el -mcpu=mips64 -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,HAS-DCLO,ACCMULDIV %s |
| 3 | ; RUN: llc -march=mips64el -mcpu=mips64r2 -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,HAS-DCLO,ACCMULDIV %s |
| 4 | ; RUN: llc -march=mips64el -mcpu=mips64r6 -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,HAS-DCLO,GPRMULDIV %s |
Akira Hatanaka | 86c3c79 | 2013-10-15 01:06:30 +0000 | [diff] [blame] | 5 | |
| 6 | @gll0 = common global i64 0, align 8 |
| 7 | @gll1 = common global i64 0, align 8 |
Akira Hatanaka | 3603641 | 2011-09-29 20:37:56 +0000 | [diff] [blame] | 8 | |
| 9 | define i64 @f0(i64 %a0, i64 %a1) nounwind readnone { |
| 10 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 11 | ; ALL-LABEL: f0: |
| 12 | ; ALL: daddu $2, ${{[45]}}, ${{[45]}} |
Akira Hatanaka | 3603641 | 2011-09-29 20:37:56 +0000 | [diff] [blame] | 13 | %add = add nsw i64 %a1, %a0 |
| 14 | ret i64 %add |
| 15 | } |
| 16 | |
| 17 | define i64 @f1(i64 %a0, i64 %a1) nounwind readnone { |
| 18 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 19 | ; ALL-LABEL: f1: |
| 20 | ; ALL: dsubu $2, $4, $5 |
Akira Hatanaka | 3603641 | 2011-09-29 20:37:56 +0000 | [diff] [blame] | 21 | %sub = sub nsw i64 %a0, %a1 |
| 22 | ret i64 %sub |
| 23 | } |
| 24 | |
| 25 | define i64 @f4(i64 %a0, i64 %a1) nounwind readnone { |
| 26 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 27 | ; ALL-LABEL: f4: |
| 28 | ; ALL: and $2, ${{[45]}}, ${{[45]}} |
Akira Hatanaka | 3603641 | 2011-09-29 20:37:56 +0000 | [diff] [blame] | 29 | %and = and i64 %a1, %a0 |
| 30 | ret i64 %and |
| 31 | } |
| 32 | |
| 33 | define i64 @f5(i64 %a0, i64 %a1) nounwind readnone { |
| 34 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 35 | ; ALL-LABEL: f5: |
| 36 | ; ALL: or $2, ${{[45]}}, ${{[45]}} |
Akira Hatanaka | 3603641 | 2011-09-29 20:37:56 +0000 | [diff] [blame] | 37 | %or = or i64 %a1, %a0 |
| 38 | ret i64 %or |
| 39 | } |
| 40 | |
| 41 | define i64 @f6(i64 %a0, i64 %a1) nounwind readnone { |
| 42 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 43 | ; ALL-LABEL: f6: |
| 44 | ; ALL: xor $2, ${{[45]}}, ${{[45]}} |
Akira Hatanaka | 3603641 | 2011-09-29 20:37:56 +0000 | [diff] [blame] | 45 | %xor = xor i64 %a1, %a0 |
| 46 | ret i64 %xor |
| 47 | } |
Akira Hatanaka | 7769a77 | 2011-09-30 02:08:54 +0000 | [diff] [blame] | 48 | |
| 49 | define i64 @f7(i64 %a0) nounwind readnone { |
| 50 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 51 | ; ALL-LABEL: f7: |
| 52 | ; ALL: daddiu $2, $4, 20 |
Akira Hatanaka | 7769a77 | 2011-09-30 02:08:54 +0000 | [diff] [blame] | 53 | %add = add nsw i64 %a0, 20 |
| 54 | ret i64 %add |
| 55 | } |
| 56 | |
| 57 | define i64 @f8(i64 %a0) nounwind readnone { |
| 58 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 59 | ; ALL-LABEL: f8: |
| 60 | ; ALL: daddiu $2, $4, -20 |
Akira Hatanaka | 7769a77 | 2011-09-30 02:08:54 +0000 | [diff] [blame] | 61 | %sub = add nsw i64 %a0, -20 |
| 62 | ret i64 %sub |
| 63 | } |
| 64 | |
| 65 | define i64 @f9(i64 %a0) nounwind readnone { |
| 66 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 67 | ; ALL-LABEL: f9: |
| 68 | ; ALL: andi $2, $4, 20 |
Akira Hatanaka | 7769a77 | 2011-09-30 02:08:54 +0000 | [diff] [blame] | 69 | %and = and i64 %a0, 20 |
| 70 | ret i64 %and |
| 71 | } |
| 72 | |
| 73 | define i64 @f10(i64 %a0) nounwind readnone { |
| 74 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 75 | ; ALL-LABEL: f10: |
| 76 | ; ALL: ori $2, $4, 20 |
Akira Hatanaka | 7769a77 | 2011-09-30 02:08:54 +0000 | [diff] [blame] | 77 | %or = or i64 %a0, 20 |
| 78 | ret i64 %or |
| 79 | } |
| 80 | |
| 81 | define i64 @f11(i64 %a0) nounwind readnone { |
| 82 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 83 | ; ALL-LABEL: f11: |
| 84 | ; ALL: xori $2, $4, 20 |
Akira Hatanaka | 7769a77 | 2011-09-30 02:08:54 +0000 | [diff] [blame] | 85 | %xor = xor i64 %a0, 20 |
| 86 | ret i64 %xor |
| 87 | } |
| 88 | |
Akira Hatanaka | a279d9b | 2011-10-03 20:01:11 +0000 | [diff] [blame] | 89 | define i64 @f12(i64 %a, i64 %b) nounwind readnone { |
| 90 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 91 | ; ALL-LABEL: f12: |
Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 92 | |
| 93 | ; ACCMULDIV: mult ${{[45]}}, ${{[45]}} |
| 94 | ; GPRMULDIV: dmul $2, ${{[45]}}, ${{[45]}} |
| 95 | |
Akira Hatanaka | a279d9b | 2011-10-03 20:01:11 +0000 | [diff] [blame] | 96 | %mul = mul nsw i64 %b, %a |
| 97 | ret i64 %mul |
| 98 | } |
| 99 | |
| 100 | define i64 @f13(i64 %a, i64 %b) nounwind readnone { |
| 101 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 102 | ; ALL-LABEL: f13: |
Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 103 | |
| 104 | ; ACCMULDIV: mult ${{[45]}}, ${{[45]}} |
| 105 | ; GPRMULDIV: dmul $2, ${{[45]}}, ${{[45]}} |
| 106 | |
Akira Hatanaka | a279d9b | 2011-10-03 20:01:11 +0000 | [diff] [blame] | 107 | %mul = mul i64 %b, %a |
| 108 | ret i64 %mul |
| 109 | } |
Akira Hatanaka | b1538f9 | 2011-10-03 21:06:13 +0000 | [diff] [blame] | 110 | |
| 111 | define i64 @f14(i64 %a, i64 %b) nounwind readnone { |
| 112 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 113 | ; ALL-LABEL: f14: |
Simon Dardis | ca74dd7 | 2017-01-27 11:36:52 +0000 | [diff] [blame] | 114 | ; ALL-DAG: ld $[[T0:[0-9]+]], %lo(gll0)(${{[0-9]+}}) |
| 115 | ; ALL-DAG: ld $[[T1:[0-9]+]], %lo(gll1)(${{[0-9]+}}) |
Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 116 | |
| 117 | ; ACCMULDIV: ddiv $zero, $[[T0]], $[[T1]] |
| 118 | ; ACCMULDIV: teq $[[T1]], $zero, 7 |
| 119 | ; ACCMULDIV: mflo $2 |
| 120 | |
| 121 | ; GPRMULDIV: ddiv $2, $[[T0]], $[[T1]] |
| 122 | ; GPRMULDIV: teq $[[T1]], $zero, 7 |
| 123 | |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 124 | %0 = load i64, i64* @gll0, align 8 |
| 125 | %1 = load i64, i64* @gll1, align 8 |
Akira Hatanaka | 86c3c79 | 2013-10-15 01:06:30 +0000 | [diff] [blame] | 126 | %div = sdiv i64 %0, %1 |
Akira Hatanaka | b1538f9 | 2011-10-03 21:06:13 +0000 | [diff] [blame] | 127 | ret i64 %div |
| 128 | } |
| 129 | |
Akira Hatanaka | 86c3c79 | 2013-10-15 01:06:30 +0000 | [diff] [blame] | 130 | define i64 @f15() nounwind readnone { |
Akira Hatanaka | b1538f9 | 2011-10-03 21:06:13 +0000 | [diff] [blame] | 131 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 132 | ; ALL-LABEL: f15: |
Simon Dardis | ca74dd7 | 2017-01-27 11:36:52 +0000 | [diff] [blame] | 133 | ; ALL-DAG: ld $[[T0:[0-9]+]], %lo(gll0)(${{[0-9]+}}) |
| 134 | ; ALL-DAG: ld $[[T1:[0-9]+]], %lo(gll1)(${{[0-9]+}}) |
Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 135 | |
| 136 | ; ACCMULDIV: ddivu $zero, $[[T0]], $[[T1]] |
| 137 | ; ACCMULDIV: teq $[[T1]], $zero, 7 |
| 138 | ; ACCMULDIV: mflo $2 |
| 139 | |
| 140 | ; GPRMULDIV: ddivu $2, $[[T0]], $[[T1]] |
| 141 | ; GPRMULDIV: teq $[[T1]], $zero, 7 |
| 142 | |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 143 | %0 = load i64, i64* @gll0, align 8 |
| 144 | %1 = load i64, i64* @gll1, align 8 |
Akira Hatanaka | 86c3c79 | 2013-10-15 01:06:30 +0000 | [diff] [blame] | 145 | %div = udiv i64 %0, %1 |
Akira Hatanaka | b1538f9 | 2011-10-03 21:06:13 +0000 | [diff] [blame] | 146 | ret i64 %div |
| 147 | } |
| 148 | |
| 149 | define i64 @f16(i64 %a, i64 %b) nounwind readnone { |
| 150 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 151 | ; ALL-LABEL: f16: |
Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 152 | |
| 153 | ; ACCMULDIV: ddiv $zero, $4, $5 |
| 154 | ; ACCMULDIV: teq $5, $zero, 7 |
| 155 | ; ACCMULDIV: mfhi $2 |
| 156 | |
| 157 | ; GPRMULDIV: dmod $2, $4, $5 |
| 158 | ; GPRMULDIV: teq $5, $zero, 7 |
| 159 | |
Akira Hatanaka | b1538f9 | 2011-10-03 21:06:13 +0000 | [diff] [blame] | 160 | %rem = srem i64 %a, %b |
| 161 | ret i64 %rem |
| 162 | } |
| 163 | |
| 164 | define i64 @f17(i64 %a, i64 %b) nounwind readnone { |
| 165 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 166 | ; ALL-LABEL: f17: |
Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 167 | |
| 168 | ; ACCMULDIV: ddivu $zero, $4, $5 |
| 169 | ; ACCMULDIV: teq $5, $zero, 7 |
| 170 | ; ACCMULDIV: mfhi $2 |
| 171 | |
| 172 | ; GPRMULDIV: dmodu $2, $4, $5 |
| 173 | ; GPRMULDIV: teq $5, $zero, 7 |
| 174 | |
Akira Hatanaka | b1538f9 | 2011-10-03 21:06:13 +0000 | [diff] [blame] | 175 | %rem = urem i64 %a, %b |
| 176 | ret i64 %rem |
| 177 | } |
| 178 | |
Chandler Carruth | 6b0e34c | 2011-12-12 11:59:10 +0000 | [diff] [blame] | 179 | declare i64 @llvm.ctlz.i64(i64, i1) nounwind readnone |
Akira Hatanaka | 48a72ca | 2011-10-03 21:16:50 +0000 | [diff] [blame] | 180 | |
Akira Hatanaka | 48a72ca | 2011-10-03 21:16:50 +0000 | [diff] [blame] | 181 | define i64 @f18(i64 %X) nounwind readnone { |
| 182 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 183 | ; ALL-LABEL: f18: |
Daniel Sanders | 3d84935 | 2014-04-14 15:44:42 +0000 | [diff] [blame] | 184 | |
| 185 | ; The MIPS4 version is too long to reasonably test. At least check we don't get dclz |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 186 | ; MIPS4-NOT: dclz |
Daniel Sanders | 3d84935 | 2014-04-14 15:44:42 +0000 | [diff] [blame] | 187 | |
Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 188 | ; HAS-DCLO: dclz $2, $4 |
| 189 | |
Chandler Carruth | 6b0e34c | 2011-12-12 11:59:10 +0000 | [diff] [blame] | 190 | %tmp1 = tail call i64 @llvm.ctlz.i64(i64 %X, i1 true) |
Akira Hatanaka | 48a72ca | 2011-10-03 21:16:50 +0000 | [diff] [blame] | 191 | ret i64 %tmp1 |
| 192 | } |
| 193 | |
Akira Hatanaka | 48a72ca | 2011-10-03 21:16:50 +0000 | [diff] [blame] | 194 | define i64 @f19(i64 %X) nounwind readnone { |
| 195 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 196 | ; ALL-LABEL: f19: |
Daniel Sanders | 3d84935 | 2014-04-14 15:44:42 +0000 | [diff] [blame] | 197 | |
| 198 | ; The MIPS4 version is too long to reasonably test. At least check we don't get dclo |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 199 | ; MIPS4-NOT: dclo |
Daniel Sanders | 3d84935 | 2014-04-14 15:44:42 +0000 | [diff] [blame] | 200 | |
Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 201 | ; HAS-DCLO: dclo $2, $4 |
| 202 | |
Akira Hatanaka | 48a72ca | 2011-10-03 21:16:50 +0000 | [diff] [blame] | 203 | %neg = xor i64 %X, -1 |
Chandler Carruth | 6b0e34c | 2011-12-12 11:59:10 +0000 | [diff] [blame] | 204 | %tmp1 = tail call i64 @llvm.ctlz.i64(i64 %neg, i1 true) |
Akira Hatanaka | 48a72ca | 2011-10-03 21:16:50 +0000 | [diff] [blame] | 205 | ret i64 %tmp1 |
| 206 | } |
| 207 | |
Akira Hatanaka | c3a6357 | 2011-10-03 21:23:18 +0000 | [diff] [blame] | 208 | define i64 @f20(i64 %a, i64 %b) nounwind readnone { |
| 209 | entry: |
Daniel Sanders | 8bb4c85 | 2014-06-11 15:48:00 +0000 | [diff] [blame] | 210 | ; ALL-LABEL: f20: |
| 211 | ; ALL: nor $2, ${{[45]}}, ${{[45]}} |
Akira Hatanaka | c3a6357 | 2011-10-03 21:23:18 +0000 | [diff] [blame] | 212 | %or = or i64 %b, %a |
| 213 | %neg = xor i64 %or, -1 |
| 214 | ret i64 %neg |
| 215 | } |