Daniel Sanders | 0d97270 | 2016-06-24 12:23:17 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32 -relocation-model=pic < %s | \ |
| 2 | ; RUN: FileCheck %s -check-prefixes=ALL,MIPS32-ANY,NO-SEB-SEH,CHECK-EL,NOT-MICROMIPS |
| 3 | ; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32r2 -relocation-model=pic -verify-machineinstrs < %s | \ |
| 4 | ; RUN: FileCheck %s -check-prefixes=ALL,MIPS32-ANY,HAS-SEB-SEH,CHECK-EL,NOT-MICROMIPS |
| 5 | ; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32r6 -relocation-model=pic -verify-machineinstrs < %s | \ |
| 6 | ; RUN: FileCheck %s -check-prefixes=ALL,MIPS32-ANY,HAS-SEB-SEH,CHECK-EL,MIPSR6 |
| 7 | ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips4 -relocation-model=pic < %s | \ |
| 8 | ; RUN: FileCheck %s -check-prefixes=ALL,MIPS64-ANY,NO-SEB-SEH,CHECK-EL,NOT-MICROMIPS |
| 9 | ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64 -relocation-model=pic < %s | \ |
| 10 | ; RUN: FileCheck %s -check-prefixes=ALL,MIPS64-ANY,NO-SEB-SEH,CHECK-EL,NOT-MICROMIPS |
| 11 | ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64r2 -relocation-model=pic -verify-machineinstrs < %s | \ |
| 12 | ; RUN: FileCheck %s -check-prefixes=ALL,MIPS64-ANY,HAS-SEB-SEH,CHECK-EL,NOT-MICROMIPS |
| 13 | ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64r6 -relocation-model=pic < %s | \ |
| 14 | ; RUN: FileCheck %s -check-prefixes=ALL,MIPS64-ANY,HAS-SEB-SEH,CHECK-EL,MIPSR6 |
| 15 | ; RUN: llc -march=mips64 -O0 -mcpu=mips64r6 -relocation-model=pic -verify-machineinstrs < %s | \ |
| 16 | ; RUN: FileCheck %s -check-prefixes=ALL-LABEL,MIPS64-ANY,O0 |
| 17 | ; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32r2 -mattr=micromips -relocation-model=pic < %s | \ |
| 18 | ; RUN: FileCheck %s -check-prefixes=ALL,MIPS32-ANY,HAS-SEB-SEH,CHECK-EL,MICROMIPS |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 19 | |
| 20 | ; Keep one big-endian check so that we don't reduce testing, but don't add more |
| 21 | ; since endianness doesn't affect the body of the atomic operations. |
Daniel Sanders | 0d97270 | 2016-06-24 12:23:17 +0000 | [diff] [blame] | 22 | ; RUN: llc -march=mips --disable-machine-licm -mcpu=mips32 -relocation-model=pic < %s | \ |
| 23 | ; RUN: FileCheck %s -check-prefixes=ALL,MIPS32-ANY,NO-SEB-SEH,CHECK-EB,NOT-MICROMIPS |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 24 | |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 25 | @x = common global i32 0, align 4 |
| 26 | |
Daniel Sanders | c43cda8 | 2014-11-07 16:54:21 +0000 | [diff] [blame] | 27 | define i32 @AtomicLoadAdd32(i32 signext %incr) nounwind { |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 28 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 29 | %0 = atomicrmw add i32* @x, i32 %incr monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 30 | ret i32 %0 |
| 31 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 32 | ; ALL-LABEL: AtomicLoadAdd32: |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 33 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 34 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x) |
| 35 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)( |
| 36 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 37 | ; O0: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 38 | ; O0: ld $[[R1:[0-9]+]] |
| 39 | ; O0-NEXT: ll $[[R2:[0-9]+]], 0($[[R1]]) |
| 40 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 41 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 42 | ; ALL: ll $[[R3:[0-9]+]], 0($[[R0]]) |
| 43 | ; ALL: addu $[[R4:[0-9]+]], $[[R3]], $4 |
| 44 | ; ALL: sc $[[R4]], 0($[[R0]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 45 | ; NOT-MICROMIPS: beqz $[[R4]], [[BB0]] |
| 46 | ; MICROMIPS: beqzc $[[R4]], [[BB0]] |
| 47 | ; MIPSR6: beqzc $[[R4]], [[BB0]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Daniel Sanders | c43cda8 | 2014-11-07 16:54:21 +0000 | [diff] [blame] | 50 | define i32 @AtomicLoadNand32(i32 signext %incr) nounwind { |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 51 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 52 | %0 = atomicrmw nand i32* @x, i32 %incr monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 53 | ret i32 %0 |
| 54 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 55 | ; ALL-LABEL: AtomicLoadNand32: |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 56 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 57 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x) |
| 58 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)( |
| 59 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 60 | |
| 61 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 62 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 63 | ; ALL: ll $[[R1:[0-9]+]], 0($[[R0]]) |
| 64 | ; ALL: and $[[R3:[0-9]+]], $[[R1]], $4 |
| 65 | ; ALL: nor $[[R2:[0-9]+]], $zero, $[[R3]] |
| 66 | ; ALL: sc $[[R2]], 0($[[R0]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 67 | ; NOT-MICROMIPS: beqz $[[R2]], [[BB0]] |
| 68 | ; MICROMIPS: beqzc $[[R2]], [[BB0]] |
| 69 | ; MIPSR6: beqzc $[[R2]], [[BB0]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Daniel Sanders | c43cda8 | 2014-11-07 16:54:21 +0000 | [diff] [blame] | 72 | define i32 @AtomicSwap32(i32 signext %newval) nounwind { |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 73 | entry: |
Akira Hatanaka | 2729263 | 2011-07-18 18:52:12 +0000 | [diff] [blame] | 74 | %newval.addr = alloca i32, align 4 |
| 75 | store i32 %newval, i32* %newval.addr, align 4 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 76 | %tmp = load i32, i32* %newval.addr, align 4 |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 77 | %0 = atomicrmw xchg i32* @x, i32 %tmp monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 78 | ret i32 %0 |
| 79 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 80 | ; ALL-LABEL: AtomicSwap32: |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 81 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 82 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x) |
| 83 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x) |
| 84 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 85 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 86 | ; ALL: ll ${{[0-9]+}}, 0($[[R0]]) |
| 87 | ; ALL: sc $[[R2:[0-9]+]], 0($[[R0]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 88 | ; NOT-MICROMIPS: beqz $[[R2]], [[BB0]] |
| 89 | ; MICROMIPS: beqzc $[[R2]], [[BB0]] |
| 90 | ; MIPSR6: beqzc $[[R2]], [[BB0]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Daniel Sanders | c43cda8 | 2014-11-07 16:54:21 +0000 | [diff] [blame] | 93 | define i32 @AtomicCmpSwap32(i32 signext %oldval, i32 signext %newval) nounwind { |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 94 | entry: |
Akira Hatanaka | 2729263 | 2011-07-18 18:52:12 +0000 | [diff] [blame] | 95 | %newval.addr = alloca i32, align 4 |
| 96 | store i32 %newval, i32* %newval.addr, align 4 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 97 | %tmp = load i32, i32* %newval.addr, align 4 |
Tim Northover | e94a518 | 2014-03-11 10:48:52 +0000 | [diff] [blame] | 98 | %0 = cmpxchg i32* @x, i32 %oldval, i32 %tmp monotonic monotonic |
Tim Northover | 420a216 | 2014-06-13 14:24:07 +0000 | [diff] [blame] | 99 | %1 = extractvalue { i32, i1 } %0, 0 |
| 100 | ret i32 %1 |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 101 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 102 | ; ALL-LABEL: AtomicCmpSwap32: |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 103 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 104 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x) |
| 105 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)( |
| 106 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 107 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 108 | ; ALL: ll $2, 0($[[R0]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 109 | ; NOT-MICROMIPS: bne $2, $4, [[BB1:(\$|\.L)[A-Z_0-9]+]] |
| 110 | ; MICROMIPS: bne $2, $4, [[BB1:(\$|\.L)[A-Z_0-9]+]] |
| 111 | ; MIPSR6: bnec $2, $4, [[BB1:(\$|\.L)[A-Z_0-9]+]] |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 112 | ; ALL: sc $[[R2:[0-9]+]], 0($[[R0]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 113 | ; NOT-MICROMIPS: beqz $[[R2]], [[BB0]] |
| 114 | ; MICROMIPS: beqzc $[[R2]], [[BB0]] |
| 115 | ; MIPSR6: beqzc $[[R2]], [[BB0]] |
| 116 | ; ALL: [[BB1]]: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | |
| 120 | |
| 121 | @y = common global i8 0, align 1 |
| 122 | |
| 123 | define signext i8 @AtomicLoadAdd8(i8 signext %incr) nounwind { |
| 124 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 125 | %0 = atomicrmw add i8* @y, i8 %incr monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 126 | ret i8 %0 |
| 127 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 128 | ; ALL-LABEL: AtomicLoadAdd8: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 129 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 130 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y) |
| 131 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)( |
| 132 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 133 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 134 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 135 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 136 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 137 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 138 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 139 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 140 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 141 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 142 | ; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 143 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 144 | ; O0: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 145 | ; O0: ld $[[R10:[0-9]+]] |
| 146 | ; O0-NEXT: ll $[[R11:[0-9]+]], 0($[[R10]]) |
| 147 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 148 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 149 | ; ALL: ll $[[R12:[0-9]+]], 0($[[R2]]) |
| 150 | ; ALL: addu $[[R13:[0-9]+]], $[[R12]], $[[R9]] |
| 151 | ; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]] |
| 152 | ; ALL: and $[[R15:[0-9]+]], $[[R12]], $[[R8]] |
| 153 | ; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R14]] |
| 154 | ; ALL: sc $[[R16]], 0($[[R2]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 155 | ; NOT-MICROMIPS: beqz $[[R16]], [[BB0]] |
| 156 | ; MICROMIPS: beqzc $[[R16]], [[BB0]] |
| 157 | ; MIPSR6: beqzc $[[R16]], [[BB0]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 158 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 159 | ; ALL: and $[[R17:[0-9]+]], $[[R12]], $[[R7]] |
| 160 | ; ALL: srlv $[[R18:[0-9]+]], $[[R17]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 161 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 162 | ; NO-SEB-SEH: sll $[[R19:[0-9]+]], $[[R18]], 24 |
| 163 | ; NO-SEB-SEH: sra $2, $[[R19]], 24 |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 164 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 165 | ; HAS-SEB-SEH: seb $2, $[[R18]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | define signext i8 @AtomicLoadSub8(i8 signext %incr) nounwind { |
| 169 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 170 | %0 = atomicrmw sub i8* @y, i8 %incr monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 171 | ret i8 %0 |
| 172 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 173 | ; ALL-LABEL: AtomicLoadSub8: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 174 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 175 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y) |
| 176 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)( |
| 177 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 178 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 179 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 180 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 181 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 182 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 183 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 184 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 185 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 186 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 187 | ; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 188 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 189 | ; O0: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 190 | ; O0: ld $[[R10:[0-9]+]] |
| 191 | ; O0-NEXT: ll $[[R11:[0-9]+]], 0($[[R10]]) |
| 192 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 193 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 194 | ; ALL: ll $[[R12:[0-9]+]], 0($[[R2]]) |
| 195 | ; ALL: subu $[[R13:[0-9]+]], $[[R12]], $[[R9]] |
| 196 | ; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]] |
| 197 | ; ALL: and $[[R15:[0-9]+]], $[[R12]], $[[R8]] |
| 198 | ; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R14]] |
| 199 | ; ALL: sc $[[R16]], 0($[[R2]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 200 | ; NOT-MICROMIPS: beqz $[[R16]], [[BB0]] |
| 201 | ; MICROMIPS: beqzc $[[R16]], [[BB0]] |
| 202 | ; MIPSR6: beqzc $[[R16]], [[BB0]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 203 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 204 | ; ALL: and $[[R17:[0-9]+]], $[[R12]], $[[R7]] |
| 205 | ; ALL: srlv $[[R18:[0-9]+]], $[[R17]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 206 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 207 | ; NO-SEB-SEH: sll $[[R19:[0-9]+]], $[[R18]], 24 |
| 208 | ; NO-SEB-SEH: sra $2, $[[R19]], 24 |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 209 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 210 | ; HAS-SEB-SEH:seb $2, $[[R18]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | define signext i8 @AtomicLoadNand8(i8 signext %incr) nounwind { |
| 214 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 215 | %0 = atomicrmw nand i8* @y, i8 %incr monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 216 | ret i8 %0 |
| 217 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 218 | ; ALL-LABEL: AtomicLoadNand8: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 219 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 220 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y) |
| 221 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)( |
| 222 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 223 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 224 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 225 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 226 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 227 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 228 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 229 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 230 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 231 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 232 | ; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 233 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 234 | ; O0: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 235 | ; O0: ld $[[R10:[0-9]+]] |
| 236 | ; O0-NEXT: ll $[[R11:[0-9]+]], 0($[[R10]]) |
| 237 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 238 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 239 | ; ALL: ll $[[R12:[0-9]+]], 0($[[R2]]) |
| 240 | ; ALL: and $[[R13:[0-9]+]], $[[R12]], $[[R9]] |
| 241 | ; ALL: nor $[[R14:[0-9]+]], $zero, $[[R13]] |
| 242 | ; ALL: and $[[R15:[0-9]+]], $[[R14]], $[[R7]] |
| 243 | ; ALL: and $[[R16:[0-9]+]], $[[R12]], $[[R8]] |
| 244 | ; ALL: or $[[R17:[0-9]+]], $[[R16]], $[[R15]] |
| 245 | ; ALL: sc $[[R17]], 0($[[R2]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 246 | ; NOT-MICROMIPS: beqz $[[R17]], [[BB0]] |
| 247 | ; MICROMIPS: beqzc $[[R17]], [[BB0]] |
| 248 | ; MIPSR6: beqzc $[[R17]], [[BB0]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 249 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 250 | ; ALL: and $[[R18:[0-9]+]], $[[R12]], $[[R7]] |
| 251 | ; ALL: srlv $[[R19:[0-9]+]], $[[R18]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 252 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 253 | ; NO-SEB-SEH: sll $[[R20:[0-9]+]], $[[R19]], 24 |
| 254 | ; NO-SEB-SEH: sra $2, $[[R20]], 24 |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 255 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 256 | ; HAS-SEB-SEH: seb $2, $[[R19]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 257 | } |
| 258 | |
Akira Hatanaka | 2729263 | 2011-07-18 18:52:12 +0000 | [diff] [blame] | 259 | define signext i8 @AtomicSwap8(i8 signext %newval) nounwind { |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 260 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 261 | %0 = atomicrmw xchg i8* @y, i8 %newval monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 262 | ret i8 %0 |
| 263 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 264 | ; ALL-LABEL: AtomicSwap8: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 265 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 266 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y) |
| 267 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)( |
| 268 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 269 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 270 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 271 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 272 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 273 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 274 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 275 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 276 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 277 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 278 | ; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 279 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 280 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 281 | ; ALL: ll $[[R10:[0-9]+]], 0($[[R2]]) |
| 282 | ; ALL: and $[[R18:[0-9]+]], $[[R9]], $[[R7]] |
| 283 | ; ALL: and $[[R13:[0-9]+]], $[[R10]], $[[R8]] |
| 284 | ; ALL: or $[[R14:[0-9]+]], $[[R13]], $[[R18]] |
| 285 | ; ALL: sc $[[R14]], 0($[[R2]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 286 | ; NOT-MICROMIPS: beqz $[[R14]], [[BB0]] |
| 287 | ; MICROMIPS: beqzc $[[R14]], [[BB0]] |
| 288 | ; MIPSR6: beqzc $[[R14]], [[BB0]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 289 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 290 | ; ALL: and $[[R15:[0-9]+]], $[[R10]], $[[R7]] |
| 291 | ; ALL: srlv $[[R16:[0-9]+]], $[[R15]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 292 | |
| 293 | ; NO-SEB-SEH: sll $[[R17:[0-9]+]], $[[R16]], 24 |
| 294 | ; NO-SEB-SEH: sra $2, $[[R17]], 24 |
| 295 | |
| 296 | ; HAS-SEB-SEH: seb $2, $[[R16]] |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 297 | |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | define signext i8 @AtomicCmpSwap8(i8 signext %oldval, i8 signext %newval) nounwind { |
| 301 | entry: |
Tim Northover | 420a216 | 2014-06-13 14:24:07 +0000 | [diff] [blame] | 302 | %pair0 = cmpxchg i8* @y, i8 %oldval, i8 %newval monotonic monotonic |
| 303 | %0 = extractvalue { i8, i1 } %pair0, 0 |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 304 | ret i8 %0 |
| 305 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 306 | ; ALL-LABEL: AtomicCmpSwap8: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 307 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 308 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y) |
| 309 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)( |
| 310 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 311 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 312 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 313 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 314 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 315 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 316 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 317 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 318 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 319 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 320 | ; ALL: andi $[[R9:[0-9]+]], $4, 255 |
| 321 | ; ALL: sllv $[[R10:[0-9]+]], $[[R9]], $[[R5]] |
| 322 | ; ALL: andi $[[R11:[0-9]+]], $5, 255 |
| 323 | ; ALL: sllv $[[R12:[0-9]+]], $[[R11]], $[[R5]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 324 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 325 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 326 | ; ALL: ll $[[R13:[0-9]+]], 0($[[R2]]) |
| 327 | ; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]] |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 328 | ; NOT-MICROMIPS: bne $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]] |
| 329 | ; MICROMIPS: bne $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]] |
| 330 | ; MIPSR6: bnec $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 331 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 332 | ; ALL: and $[[R15:[0-9]+]], $[[R13]], $[[R8]] |
| 333 | ; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R12]] |
| 334 | ; ALL: sc $[[R16]], 0($[[R2]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 335 | ; NOT-MICROMIPS: beqz $[[R16]], [[BB0]] |
| 336 | ; MICROMIPS: beqzc $[[R16]], [[BB0]] |
| 337 | ; MIPSR6: beqzc $[[R16]], [[BB0]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 338 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 339 | ; ALL: [[BB1]]: |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 340 | ; ALL: srlv $[[R17:[0-9]+]], $[[R14]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 341 | |
| 342 | ; NO-SEB-SEH: sll $[[R18:[0-9]+]], $[[R17]], 24 |
| 343 | ; NO-SEB-SEH: sra $2, $[[R18]], 24 |
| 344 | |
| 345 | ; HAS-SEB-SEH: seb $2, $[[R17]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 346 | } |
Akira Hatanaka | a4c09bc | 2011-07-19 23:30:50 +0000 | [diff] [blame] | 347 | |
Daniel Sanders | c43cda8 | 2014-11-07 16:54:21 +0000 | [diff] [blame] | 348 | define i1 @AtomicCmpSwapRes8(i8* %ptr, i8 signext %oldval, i8 signext %newval) nounwind { |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 349 | entry: |
| 350 | %0 = cmpxchg i8* %ptr, i8 %oldval, i8 %newval monotonic monotonic |
| 351 | %1 = extractvalue { i8, i1 } %0, 1 |
| 352 | ret i1 %1 |
| 353 | ; ALL-LABEL: AtomicCmpSwapRes8 |
| 354 | |
| 355 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 356 | ; ALL: and $[[R2:[0-9]+]], $4, $[[R1]] |
| 357 | ; ALL: andi $[[R3:[0-9]+]], $4, 3 |
| 358 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 359 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 360 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 361 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 362 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 363 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 364 | ; ALL: andi $[[R9:[0-9]+]], $5, 255 |
| 365 | ; ALL: sllv $[[R10:[0-9]+]], $[[R9]], $[[R5]] |
| 366 | ; ALL: andi $[[R11:[0-9]+]], $6, 255 |
| 367 | ; ALL: sllv $[[R12:[0-9]+]], $[[R11]], $[[R5]] |
| 368 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 369 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 370 | ; ALL: ll $[[R13:[0-9]+]], 0($[[R2]]) |
| 371 | ; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]] |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 372 | ; NOT-MICROMIPS: bne $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]] |
| 373 | ; MICROMIPS: bne $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]] |
| 374 | ; MIPSR6: bnec $[[R14]], $[[R10]], [[BB1:(\$|\.L)[A-Z_0-9]+]] |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 375 | |
| 376 | ; ALL: and $[[R15:[0-9]+]], $[[R13]], $[[R8]] |
| 377 | ; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R12]] |
| 378 | ; ALL: sc $[[R16]], 0($[[R2]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 379 | ; NOT-MICROMIPS: beqz $[[R16]], [[BB0]] |
| 380 | ; MICROMIPS: beqzc $[[R16]], [[BB0]] |
| 381 | ; MIPSR6: beqzc $[[R16]], [[BB0]] |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 382 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 383 | ; ALL: [[BB1]]: |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 384 | ; ALL: srlv $[[R17:[0-9]+]], $[[R14]], $[[R5]] |
| 385 | |
| 386 | ; NO-SEB-SEH: sll $[[R18:[0-9]+]], $[[R17]], 24 |
| 387 | ; NO-SEB-SEH: sra $[[R19:[0-9]+]], $[[R18]], 24 |
| 388 | |
Tim Northover | 4498eff | 2016-03-24 15:38:38 +0000 | [diff] [blame] | 389 | ; FIXME: -march=mips produces a redundant sign extension here... |
| 390 | ; NO-SEB-SEH: sll $[[R20:[0-9]+]], $5, 24 |
| 391 | ; NO-SEB-SEH: sra $[[R20]], $[[R20]], 24 |
| 392 | |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 393 | ; HAS-SEB-SEH: seb $[[R19:[0-9]+]], $[[R17]] |
| 394 | |
Tim Northover | 4498eff | 2016-03-24 15:38:38 +0000 | [diff] [blame] | 395 | ; FIXME: ...Leading to this split check. |
| 396 | ; NO-SEB-SEH: xor $[[R21:[0-9]+]], $[[R19]], $[[R20]] |
| 397 | ; HAS-SEB-SEH: xor $[[R21:[0-9]+]], $[[R19]], $5 |
| 398 | |
| 399 | ; ALL: sltiu $2, $[[R21]], 1 |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 400 | } |
| 401 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 402 | ; Check one i16 so that we cover the seh sign extend |
| 403 | @z = common global i16 0, align 1 |
| 404 | |
| 405 | define signext i16 @AtomicLoadAdd16(i16 signext %incr) nounwind { |
| 406 | entry: |
| 407 | %0 = atomicrmw add i16* @z, i16 %incr monotonic |
| 408 | ret i16 %0 |
| 409 | |
| 410 | ; ALL-LABEL: AtomicLoadAdd16: |
| 411 | |
| 412 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(z) |
| 413 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(z)( |
| 414 | |
| 415 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 416 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 417 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 418 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 2 |
| 419 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 420 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 421 | ; ALL: ori $[[R6:[0-9]+]], $zero, 65535 |
| 422 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 423 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 424 | ; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]] |
| 425 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 426 | ; O0: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 427 | ; O0: ld $[[R10:[0-9]+]] |
| 428 | ; O0-NEXT: ll $[[R11:[0-9]+]], 0($[[R10]]) |
| 429 | |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 430 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 431 | ; ALL: ll $[[R12:[0-9]+]], 0($[[R2]]) |
| 432 | ; ALL: addu $[[R13:[0-9]+]], $[[R12]], $[[R9]] |
| 433 | ; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]] |
| 434 | ; ALL: and $[[R15:[0-9]+]], $[[R12]], $[[R8]] |
| 435 | ; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R14]] |
| 436 | ; ALL: sc $[[R16]], 0($[[R2]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 437 | ; NOT-MICROMIPS: beqz $[[R16]], [[BB0]] |
| 438 | ; MICROMIPS: beqzc $[[R16]], [[BB0]] |
| 439 | ; MIPSR6: beqzc $[[R16]], [[BB0]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 440 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 441 | ; ALL: and $[[R17:[0-9]+]], $[[R12]], $[[R7]] |
| 442 | ; ALL: srlv $[[R18:[0-9]+]], $[[R17]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 443 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 444 | ; NO-SEB-SEH: sll $[[R19:[0-9]+]], $[[R18]], 16 |
| 445 | ; NO-SEB-SEH: sra $2, $[[R19]], 16 |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 446 | |
Simon Dardis | a2d8cc3 | 2016-04-28 16:26:43 +0000 | [diff] [blame] | 447 | ; MIPS32R2: seh $2, $[[R18]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 448 | } |
| 449 | |
Tim Northover | 4498eff | 2016-03-24 15:38:38 +0000 | [diff] [blame] | 450 | ; Test that the i16 return value from cmpxchg is recognised as signed, |
| 451 | ; so that setCC doesn't end up comparing an unsigned value to a signed |
| 452 | ; value. |
| 453 | ; The rest of the functions here are testing the atomic expansion, so |
| 454 | ; we just match the end of the function. |
| 455 | define {i16, i1} @foo(i16* %addr, i16 %l, i16 %r, i16 %new) { |
| 456 | %desired = add i16 %l, %r |
| 457 | %res = cmpxchg i16* %addr, i16 %desired, i16 %new seq_cst seq_cst |
| 458 | ret {i16, i1} %res |
| 459 | |
| 460 | ; ALL-LABEL: foo |
| 461 | ; MIPSR6: addu $[[R2:[0-9]+]], $[[R1:[0-9]+]], $[[R0:[0-9]+]] |
| 462 | ; NOT-MICROMIPS: addu $[[R2:[0-9]+]], $[[R1:[0-9]+]], $[[R0:[0-9]+]] |
| 463 | ; MICROMIPS: addu16 $[[R2:[0-9]+]], $[[R1:[0-9]+]], $[[R0:[0-9]+]] |
| 464 | |
| 465 | ; ALL: sync |
| 466 | |
| 467 | ; ALL: andi $[[R3:[0-9]+]], $[[R2]], 65535 |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 468 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Tim Northover | 4498eff | 2016-03-24 15:38:38 +0000 | [diff] [blame] | 469 | ; ALL: ll $[[R4:[0-9]+]], 0($[[R5:[0-9]+]]) |
| 470 | ; ALL: and $[[R6:[0-9]+]], $[[R4]], $ |
| 471 | ; ALL: and $[[R7:[0-9]+]], $[[R4]], $ |
| 472 | ; ALL: or $[[R8:[0-9]+]], $[[R7]], $ |
| 473 | ; ALL: sc $[[R8]], 0($[[R5]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 474 | ; NOT-MICROMIPS: beqz $[[R8]], [[BB0]] |
| 475 | ; MICROMIPS: beqzc $[[R8]], [[BB0]] |
| 476 | ; MIPSR6: beqzc $[[R8]], [[BB0]] |
Tim Northover | 4498eff | 2016-03-24 15:38:38 +0000 | [diff] [blame] | 477 | |
| 478 | ; ALL: srlv $[[R9:[0-9]+]], $[[R6]], $ |
| 479 | |
| 480 | ; NO-SEB-SEH: sll $[[R10:[0-9]+]], $[[R9]], 16 |
| 481 | ; NO-SEB-SEH: sra $[[R11:[0-9]+]], $[[R10]], 16 |
| 482 | |
| 483 | ; NO-SEB-SEH: sll $[[R12:[0-9]+]], $[[R2]], 16 |
| 484 | ; NO-SEB-SEH: sra $[[R13:[0-9]+]], $[[R12]], 16 |
| 485 | |
| 486 | ; HAS-SEB-SEH: seh $[[R11:[0-9]+]], $[[R9]] |
| 487 | ; HAS-SEB-SEH: seh $[[R13:[0-9]+]], $[[R2]] |
| 488 | |
| 489 | ; ALL: xor $[[R12:[0-9]+]], $[[R11]], $[[R13]] |
| 490 | ; ALL: sltiu $3, $[[R12]], 1 |
| 491 | ; ALL: sync |
| 492 | } |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 493 | |
Akira Hatanaka | a4c09bc | 2011-07-19 23:30:50 +0000 | [diff] [blame] | 494 | @countsint = common global i32 0, align 4 |
| 495 | |
Daniel Sanders | c43cda8 | 2014-11-07 16:54:21 +0000 | [diff] [blame] | 496 | define i32 @CheckSync(i32 signext %v) nounwind noinline { |
Akira Hatanaka | a4c09bc | 2011-07-19 23:30:50 +0000 | [diff] [blame] | 497 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 498 | %0 = atomicrmw add i32* @countsint, i32 %v seq_cst |
Akira Hatanaka | a4c09bc | 2011-07-19 23:30:50 +0000 | [diff] [blame] | 499 | ret i32 %0 |
| 500 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 501 | ; ALL-LABEL: CheckSync: |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 502 | |
Matheus Almeida | 784f797 | 2014-06-18 17:10:30 +0000 | [diff] [blame] | 503 | ; ALL: sync |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 504 | ; ALL: ll |
| 505 | ; ALL: sc |
| 506 | ; ALL: beq |
Matheus Almeida | 784f797 | 2014-06-18 17:10:30 +0000 | [diff] [blame] | 507 | ; ALL: sync |
Akira Hatanaka | a4c09bc | 2011-07-19 23:30:50 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Akira Hatanaka | 0661b81 | 2012-05-11 23:22:18 +0000 | [diff] [blame] | 510 | ; make sure that this assertion in |
| 511 | ; TwoAddressInstructionPass::TryInstructionTransform does not fail: |
| 512 | ; |
| 513 | ; line 1203: assert(TargetRegisterInfo::isVirtualRegister(regB) && |
| 514 | ; |
| 515 | ; it failed when MipsDAGToDAGISel::ReplaceUsesWithZeroReg replaced an |
| 516 | ; operand of an atomic instruction with register $zero. |
| 517 | @a = external global i32 |
| 518 | |
| 519 | define i32 @zeroreg() nounwind { |
| 520 | entry: |
Tim Northover | 420a216 | 2014-06-13 14:24:07 +0000 | [diff] [blame] | 521 | %pair0 = cmpxchg i32* @a, i32 1, i32 0 seq_cst seq_cst |
| 522 | %0 = extractvalue { i32, i1 } %pair0, 0 |
Akira Hatanaka | 0661b81 | 2012-05-11 23:22:18 +0000 | [diff] [blame] | 523 | %1 = icmp eq i32 %0, 1 |
| 524 | %conv = zext i1 %1 to i32 |
| 525 | ret i32 %conv |
| 526 | } |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 527 | |
| 528 | ; Check that MIPS32R6 has the correct offset range. |
| 529 | ; FIXME: At the moment, we don't seem to do addr+offset for any atomic load/store. |
Daniel Sanders | c43cda8 | 2014-11-07 16:54:21 +0000 | [diff] [blame] | 530 | define i32 @AtomicLoadAdd32_OffGt9Bit(i32 signext %incr) nounwind { |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 531 | entry: |
David Blaikie | f72d05b | 2015-03-13 18:20:45 +0000 | [diff] [blame] | 532 | %0 = atomicrmw add i32* getelementptr(i32, i32* @x, i32 256), i32 %incr monotonic |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 533 | ret i32 %0 |
| 534 | |
| 535 | ; ALL-LABEL: AtomicLoadAdd32_OffGt9Bit: |
| 536 | |
| 537 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x) |
| 538 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)( |
| 539 | |
| 540 | ; ALL: addiu $[[PTR:[0-9]+]], $[[R0]], 1024 |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 541 | ; ALL: [[BB0:(\$|\.L)[A-Z_0-9]+]]: |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 542 | ; ALL: ll $[[R1:[0-9]+]], 0($[[PTR]]) |
| 543 | ; ALL: addu $[[R2:[0-9]+]], $[[R1]], $4 |
| 544 | ; ALL: sc $[[R2]], 0($[[PTR]]) |
Daniel Sanders | 6a73883 | 2016-07-19 10:49:03 +0000 | [diff] [blame] | 545 | ; NOT-MICROMIPS: beqz $[[R2]], [[BB0]] |
| 546 | ; MICROMIPS: beqzc $[[R2]], [[BB0]] |
| 547 | ; MIPSR6: beqzc $[[R2]], [[BB0]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 548 | } |