Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS32-ANY -check-prefix=NO-SEB-SEH -check-prefix=CHECK-EL |
| 2 | ; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32r2 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS32-ANY -check-prefix=HAS-SEB-SEH -check-prefix=CHECK-EL |
| 3 | ; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32r6 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS32-ANY -check-prefix=HAS-SEB-SEH -check-prefix=CHECK-EL |
| 4 | ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips4 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS64-ANY -check-prefix=NO-SEB-SEH -check-prefix=CHECK-EL |
| 5 | ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS64-ANY -check-prefix=NO-SEB-SEH -check-prefix=CHECK-EL |
| 6 | ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64r2 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS64-ANY -check-prefix=HAS-SEB-SEH -check-prefix=CHECK-EL |
| 7 | ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64r6 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS64-ANY -check-prefix=HAS-SEB-SEH -check-prefix=CHECK-EL |
| 8 | |
| 9 | ; Keep one big-endian check so that we don't reduce testing, but don't add more |
| 10 | ; since endianness doesn't affect the body of the atomic operations. |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 11 | ; RUN: llc -march=mips --disable-machine-licm -mcpu=mips32 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS32-ANY -check-prefix=NO-SEB-SEH -check-prefix=CHECK-EB |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 12 | |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 13 | @x = common global i32 0, align 4 |
| 14 | |
| 15 | define i32 @AtomicLoadAdd32(i32 %incr) nounwind { |
| 16 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 17 | %0 = atomicrmw add i32* @x, i32 %incr monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 18 | ret i32 %0 |
| 19 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 20 | ; ALL-LABEL: AtomicLoadAdd32: |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 21 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 22 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x) |
| 23 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)( |
| 24 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 25 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 26 | ; ALL: ll $[[R1:[0-9]+]], 0($[[R0]]) |
| 27 | ; ALL: addu $[[R2:[0-9]+]], $[[R1]], $4 |
| 28 | ; ALL: sc $[[R2]], 0($[[R0]]) |
| 29 | ; ALL: beqz $[[R2]], $[[BB0]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | define i32 @AtomicLoadNand32(i32 %incr) nounwind { |
| 33 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 34 | %0 = atomicrmw nand i32* @x, i32 %incr monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 35 | ret i32 %0 |
| 36 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 37 | ; ALL-LABEL: AtomicLoadNand32: |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 38 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 39 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x) |
| 40 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)( |
| 41 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 42 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 43 | ; ALL: ll $[[R1:[0-9]+]], 0($[[R0]]) |
| 44 | ; ALL: and $[[R3:[0-9]+]], $[[R1]], $4 |
| 45 | ; ALL: nor $[[R2:[0-9]+]], $zero, $[[R3]] |
| 46 | ; ALL: sc $[[R2]], 0($[[R0]]) |
| 47 | ; ALL: beqz $[[R2]], $[[BB0]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Akira Hatanaka | 2729263 | 2011-07-18 18:52:12 +0000 | [diff] [blame] | 50 | define i32 @AtomicSwap32(i32 %newval) nounwind { |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 51 | entry: |
Akira Hatanaka | 2729263 | 2011-07-18 18:52:12 +0000 | [diff] [blame] | 52 | %newval.addr = alloca i32, align 4 |
| 53 | store i32 %newval, i32* %newval.addr, align 4 |
| 54 | %tmp = load i32* %newval.addr, align 4 |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 55 | %0 = atomicrmw xchg i32* @x, i32 %tmp monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 56 | ret i32 %0 |
| 57 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 58 | ; ALL-LABEL: AtomicSwap32: |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 59 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 60 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x) |
| 61 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x) |
| 62 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 63 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 64 | ; ALL: ll ${{[0-9]+}}, 0($[[R0]]) |
| 65 | ; ALL: sc $[[R2:[0-9]+]], 0($[[R0]]) |
| 66 | ; ALL: beqz $[[R2]], $[[BB0]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | define i32 @AtomicCmpSwap32(i32 %oldval, i32 %newval) nounwind { |
| 70 | entry: |
Akira Hatanaka | 2729263 | 2011-07-18 18:52:12 +0000 | [diff] [blame] | 71 | %newval.addr = alloca i32, align 4 |
| 72 | store i32 %newval, i32* %newval.addr, align 4 |
| 73 | %tmp = load i32* %newval.addr, align 4 |
Tim Northover | e94a518 | 2014-03-11 10:48:52 +0000 | [diff] [blame] | 74 | %0 = cmpxchg i32* @x, i32 %oldval, i32 %tmp monotonic monotonic |
Tim Northover | 420a216 | 2014-06-13 14:24:07 +0000 | [diff] [blame] | 75 | %1 = extractvalue { i32, i1 } %0, 0 |
| 76 | ret i32 %1 |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 77 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 78 | ; ALL-LABEL: AtomicCmpSwap32: |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 79 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 80 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x) |
| 81 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)( |
| 82 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 83 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 84 | ; ALL: ll $2, 0($[[R0]]) |
| 85 | ; ALL: bne $2, $4, $[[BB1:[A-Z_0-9]+]] |
| 86 | ; ALL: sc $[[R2:[0-9]+]], 0($[[R0]]) |
| 87 | ; ALL: beqz $[[R2]], $[[BB0]] |
| 88 | ; ALL: $[[BB1]]: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | |
| 92 | |
| 93 | @y = common global i8 0, align 1 |
| 94 | |
| 95 | define signext i8 @AtomicLoadAdd8(i8 signext %incr) nounwind { |
| 96 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 97 | %0 = atomicrmw add i8* @y, i8 %incr monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 98 | ret i8 %0 |
| 99 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 100 | ; ALL-LABEL: AtomicLoadAdd8: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 101 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 102 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y) |
| 103 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)( |
| 104 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 105 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 106 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 107 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 108 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 109 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 110 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 111 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 112 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 113 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 114 | ; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 115 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 116 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 117 | ; ALL: ll $[[R10:[0-9]+]], 0($[[R2]]) |
| 118 | ; ALL: addu $[[R11:[0-9]+]], $[[R10]], $[[R9]] |
| 119 | ; ALL: and $[[R12:[0-9]+]], $[[R11]], $[[R7]] |
| 120 | ; ALL: and $[[R13:[0-9]+]], $[[R10]], $[[R8]] |
| 121 | ; ALL: or $[[R14:[0-9]+]], $[[R13]], $[[R12]] |
| 122 | ; ALL: sc $[[R14]], 0($[[R2]]) |
| 123 | ; ALL: beqz $[[R14]], $[[BB0]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 124 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 125 | ; ALL: and $[[R15:[0-9]+]], $[[R10]], $[[R7]] |
| 126 | ; ALL: srlv $[[R16:[0-9]+]], $[[R15]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 127 | |
| 128 | ; NO-SEB-SEH: sll $[[R17:[0-9]+]], $[[R16]], 24 |
| 129 | ; NO-SEB-SEH: sra $2, $[[R17]], 24 |
| 130 | |
| 131 | ; HAS-SEB-SEH: seb $2, $[[R16]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | define signext i8 @AtomicLoadSub8(i8 signext %incr) nounwind { |
| 135 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 136 | %0 = atomicrmw sub i8* @y, i8 %incr monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 137 | ret i8 %0 |
| 138 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 139 | ; ALL-LABEL: AtomicLoadSub8: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 140 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 141 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y) |
| 142 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)( |
| 143 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 144 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 145 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 146 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 147 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 148 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 149 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 150 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 151 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 152 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 153 | ; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 154 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 155 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 156 | ; ALL: ll $[[R10:[0-9]+]], 0($[[R2]]) |
| 157 | ; ALL: subu $[[R11:[0-9]+]], $[[R10]], $[[R9]] |
| 158 | ; ALL: and $[[R12:[0-9]+]], $[[R11]], $[[R7]] |
| 159 | ; ALL: and $[[R13:[0-9]+]], $[[R10]], $[[R8]] |
| 160 | ; ALL: or $[[R14:[0-9]+]], $[[R13]], $[[R12]] |
| 161 | ; ALL: sc $[[R14]], 0($[[R2]]) |
| 162 | ; ALL: beqz $[[R14]], $[[BB0]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 163 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 164 | ; ALL: and $[[R15:[0-9]+]], $[[R10]], $[[R7]] |
| 165 | ; ALL: srlv $[[R16:[0-9]+]], $[[R15]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 166 | |
| 167 | ; NO-SEB-SEH: sll $[[R17:[0-9]+]], $[[R16]], 24 |
| 168 | ; NO-SEB-SEH: sra $2, $[[R17]], 24 |
| 169 | |
| 170 | ; HAS-SEB-SEH:seb $2, $[[R16]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | define signext i8 @AtomicLoadNand8(i8 signext %incr) nounwind { |
| 174 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 175 | %0 = atomicrmw nand i8* @y, i8 %incr monotonic |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 176 | ret i8 %0 |
| 177 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 178 | ; ALL-LABEL: AtomicLoadNand8: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 179 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 180 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y) |
| 181 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)( |
| 182 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 183 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 184 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 185 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 186 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 187 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 188 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 189 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 190 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 191 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 192 | ; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 193 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 194 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 195 | ; ALL: ll $[[R10:[0-9]+]], 0($[[R2]]) |
| 196 | ; ALL: and $[[R18:[0-9]+]], $[[R10]], $[[R9]] |
| 197 | ; ALL: nor $[[R11:[0-9]+]], $zero, $[[R18]] |
| 198 | ; ALL: and $[[R12:[0-9]+]], $[[R11]], $[[R7]] |
| 199 | ; ALL: and $[[R13:[0-9]+]], $[[R10]], $[[R8]] |
| 200 | ; ALL: or $[[R14:[0-9]+]], $[[R13]], $[[R12]] |
| 201 | ; ALL: sc $[[R14]], 0($[[R2]]) |
| 202 | ; ALL: beqz $[[R14]], $[[BB0]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 203 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 204 | ; ALL: and $[[R15:[0-9]+]], $[[R10]], $[[R7]] |
| 205 | ; ALL: srlv $[[R16:[0-9]+]], $[[R15]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 206 | |
| 207 | ; NO-SEB-SEH: sll $[[R17:[0-9]+]], $[[R16]], 24 |
| 208 | ; NO-SEB-SEH: sra $2, $[[R17]], 24 |
| 209 | |
| 210 | ; HAS-SEB-SEH: seb $2, $[[R16]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Akira Hatanaka | 2729263 | 2011-07-18 18:52:12 +0000 | [diff] [blame] | 213 | define signext i8 @AtomicSwap8(i8 signext %newval) nounwind { |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 214 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 215 | %0 = atomicrmw xchg i8* @y, i8 %newval 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: AtomicSwap8: |
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 | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 234 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 235 | ; ALL: ll $[[R10:[0-9]+]], 0($[[R2]]) |
| 236 | ; ALL: and $[[R18:[0-9]+]], $[[R9]], $[[R7]] |
| 237 | ; ALL: and $[[R13:[0-9]+]], $[[R10]], $[[R8]] |
| 238 | ; ALL: or $[[R14:[0-9]+]], $[[R13]], $[[R18]] |
| 239 | ; ALL: sc $[[R14]], 0($[[R2]]) |
| 240 | ; ALL: beqz $[[R14]], $[[BB0]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 241 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 242 | ; ALL: and $[[R15:[0-9]+]], $[[R10]], $[[R7]] |
| 243 | ; ALL: srlv $[[R16:[0-9]+]], $[[R15]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 244 | |
| 245 | ; NO-SEB-SEH: sll $[[R17:[0-9]+]], $[[R16]], 24 |
| 246 | ; NO-SEB-SEH: sra $2, $[[R17]], 24 |
| 247 | |
| 248 | ; HAS-SEB-SEH: seb $2, $[[R16]] |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 249 | |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | define signext i8 @AtomicCmpSwap8(i8 signext %oldval, i8 signext %newval) nounwind { |
| 253 | entry: |
Tim Northover | 420a216 | 2014-06-13 14:24:07 +0000 | [diff] [blame] | 254 | %pair0 = cmpxchg i8* @y, i8 %oldval, i8 %newval monotonic monotonic |
| 255 | %0 = extractvalue { i8, i1 } %pair0, 0 |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 256 | ret i8 %0 |
| 257 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 258 | ; ALL-LABEL: AtomicCmpSwap8: |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 259 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 260 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(y) |
| 261 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(y)( |
| 262 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 263 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 264 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 265 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 266 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 267 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 268 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 269 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 270 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 271 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 272 | ; ALL: andi $[[R9:[0-9]+]], $4, 255 |
| 273 | ; ALL: sllv $[[R10:[0-9]+]], $[[R9]], $[[R5]] |
| 274 | ; ALL: andi $[[R11:[0-9]+]], $5, 255 |
| 275 | ; ALL: sllv $[[R12:[0-9]+]], $[[R11]], $[[R5]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 276 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 277 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 278 | ; ALL: ll $[[R13:[0-9]+]], 0($[[R2]]) |
| 279 | ; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]] |
| 280 | ; ALL: bne $[[R14]], $[[R10]], $[[BB1:[A-Z_0-9]+]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 281 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 282 | ; ALL: and $[[R15:[0-9]+]], $[[R13]], $[[R8]] |
| 283 | ; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R12]] |
| 284 | ; ALL: sc $[[R16]], 0($[[R2]]) |
| 285 | ; ALL: beqz $[[R16]], $[[BB0]] |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 286 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 287 | ; ALL: $[[BB1]]: |
| 288 | ; ALL: srlv $[[R17:[0-9]+]], $[[R14]], $[[R5]] |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 289 | |
| 290 | ; NO-SEB-SEH: sll $[[R18:[0-9]+]], $[[R17]], 24 |
| 291 | ; NO-SEB-SEH: sra $2, $[[R18]], 24 |
| 292 | |
| 293 | ; HAS-SEB-SEH: seb $2, $[[R17]] |
Bruno Cardoso Lopes | 98fc4c8 | 2011-05-31 02:54:07 +0000 | [diff] [blame] | 294 | } |
Akira Hatanaka | a4c09bc | 2011-07-19 23:30:50 +0000 | [diff] [blame] | 295 | |
Logan Chien | 63bee2a | 2014-07-21 17:33:44 +0000 | [diff] [blame] | 296 | define i1 @AtomicCmpSwapRes8(i8* %ptr, i8 %oldval, i8 signext %newval) nounwind { |
| 297 | entry: |
| 298 | %0 = cmpxchg i8* %ptr, i8 %oldval, i8 %newval monotonic monotonic |
| 299 | %1 = extractvalue { i8, i1 } %0, 1 |
| 300 | ret i1 %1 |
| 301 | ; ALL-LABEL: AtomicCmpSwapRes8 |
| 302 | |
| 303 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 304 | ; ALL: and $[[R2:[0-9]+]], $4, $[[R1]] |
| 305 | ; ALL: andi $[[R3:[0-9]+]], $4, 3 |
| 306 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 307 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 3 |
| 308 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 309 | ; ALL: ori $[[R6:[0-9]+]], $zero, 255 |
| 310 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 311 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 312 | ; ALL: andi $[[R9:[0-9]+]], $5, 255 |
| 313 | ; ALL: sllv $[[R10:[0-9]+]], $[[R9]], $[[R5]] |
| 314 | ; ALL: andi $[[R11:[0-9]+]], $6, 255 |
| 315 | ; ALL: sllv $[[R12:[0-9]+]], $[[R11]], $[[R5]] |
| 316 | |
| 317 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 318 | ; ALL: ll $[[R13:[0-9]+]], 0($[[R2]]) |
| 319 | ; ALL: and $[[R14:[0-9]+]], $[[R13]], $[[R7]] |
| 320 | ; ALL: bne $[[R14]], $[[R10]], $[[BB1:[A-Z_0-9]+]] |
| 321 | |
| 322 | ; ALL: and $[[R15:[0-9]+]], $[[R13]], $[[R8]] |
| 323 | ; ALL: or $[[R16:[0-9]+]], $[[R15]], $[[R12]] |
| 324 | ; ALL: sc $[[R16]], 0($[[R2]]) |
| 325 | ; ALL: beqz $[[R16]], $[[BB0]] |
| 326 | |
| 327 | ; ALL: $[[BB1]]: |
| 328 | ; ALL: srlv $[[R17:[0-9]+]], $[[R14]], $[[R5]] |
| 329 | |
| 330 | ; NO-SEB-SEH: sll $[[R18:[0-9]+]], $[[R17]], 24 |
| 331 | ; NO-SEB-SEH: sra $[[R19:[0-9]+]], $[[R18]], 24 |
| 332 | |
| 333 | ; HAS-SEB-SEH: seb $[[R19:[0-9]+]], $[[R17]] |
| 334 | |
| 335 | ; ALL: xor $[[R20:[0-9]+]], $[[R19]], $5 |
| 336 | ; ALL: sltiu $2, $[[R20]], 1 |
| 337 | } |
| 338 | |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 339 | ; Check one i16 so that we cover the seh sign extend |
| 340 | @z = common global i16 0, align 1 |
| 341 | |
| 342 | define signext i16 @AtomicLoadAdd16(i16 signext %incr) nounwind { |
| 343 | entry: |
| 344 | %0 = atomicrmw add i16* @z, i16 %incr monotonic |
| 345 | ret i16 %0 |
| 346 | |
| 347 | ; ALL-LABEL: AtomicLoadAdd16: |
| 348 | |
| 349 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(z) |
| 350 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(z)( |
| 351 | |
| 352 | ; ALL: addiu $[[R1:[0-9]+]], $zero, -4 |
| 353 | ; ALL: and $[[R2:[0-9]+]], $[[R0]], $[[R1]] |
| 354 | ; ALL: andi $[[R3:[0-9]+]], $[[R0]], 3 |
| 355 | ; CHECK-EB: xori $[[R4:[0-9]+]], $[[R3]], 2 |
| 356 | ; CHECK-EB: sll $[[R5:[0-9]+]], $[[R4]], 3 |
| 357 | ; CHECK-EL: sll $[[R5:[0-9]+]], $[[R3]], 3 |
| 358 | ; ALL: ori $[[R6:[0-9]+]], $zero, 65535 |
| 359 | ; ALL: sllv $[[R7:[0-9]+]], $[[R6]], $[[R5]] |
| 360 | ; ALL: nor $[[R8:[0-9]+]], $zero, $[[R7]] |
| 361 | ; ALL: sllv $[[R9:[0-9]+]], $4, $[[R5]] |
| 362 | |
| 363 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 364 | ; ALL: ll $[[R10:[0-9]+]], 0($[[R2]]) |
| 365 | ; ALL: addu $[[R11:[0-9]+]], $[[R10]], $[[R9]] |
| 366 | ; ALL: and $[[R12:[0-9]+]], $[[R11]], $[[R7]] |
| 367 | ; ALL: and $[[R13:[0-9]+]], $[[R10]], $[[R8]] |
| 368 | ; ALL: or $[[R14:[0-9]+]], $[[R13]], $[[R12]] |
| 369 | ; ALL: sc $[[R14]], 0($[[R2]]) |
| 370 | ; ALL: beqz $[[R14]], $[[BB0]] |
| 371 | |
| 372 | ; ALL: and $[[R15:[0-9]+]], $[[R10]], $[[R7]] |
| 373 | ; ALL: srlv $[[R16:[0-9]+]], $[[R15]], $[[R5]] |
| 374 | |
| 375 | ; NO-SEB-SEH: sll $[[R17:[0-9]+]], $[[R16]], 16 |
| 376 | ; NO-SEB-SEH: sra $2, $[[R17]], 16 |
| 377 | |
| 378 | ; MIPS32R2: seh $2, $[[R16]] |
| 379 | } |
| 380 | |
| 381 | |
Akira Hatanaka | a4c09bc | 2011-07-19 23:30:50 +0000 | [diff] [blame] | 382 | @countsint = common global i32 0, align 4 |
| 383 | |
| 384 | define i32 @CheckSync(i32 %v) nounwind noinline { |
| 385 | entry: |
Eli Friedman | c064f2c | 2011-09-26 20:27:49 +0000 | [diff] [blame] | 386 | %0 = atomicrmw add i32* @countsint, i32 %v seq_cst |
Akira Hatanaka | a4c09bc | 2011-07-19 23:30:50 +0000 | [diff] [blame] | 387 | ret i32 %0 |
| 388 | |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 389 | ; ALL-LABEL: CheckSync: |
Akira Hatanaka | 2bf9733 | 2013-05-31 03:25:44 +0000 | [diff] [blame] | 390 | |
Matheus Almeida | 784f797 | 2014-06-18 17:10:30 +0000 | [diff] [blame] | 391 | ; ALL: sync |
Daniel Sanders | ddb7aa6 | 2014-06-16 10:25:17 +0000 | [diff] [blame] | 392 | ; ALL: ll |
| 393 | ; ALL: sc |
| 394 | ; ALL: beq |
Matheus Almeida | 784f797 | 2014-06-18 17:10:30 +0000 | [diff] [blame] | 395 | ; ALL: sync |
Akira Hatanaka | a4c09bc | 2011-07-19 23:30:50 +0000 | [diff] [blame] | 396 | } |
| 397 | |
Akira Hatanaka | 0661b81 | 2012-05-11 23:22:18 +0000 | [diff] [blame] | 398 | ; make sure that this assertion in |
| 399 | ; TwoAddressInstructionPass::TryInstructionTransform does not fail: |
| 400 | ; |
| 401 | ; line 1203: assert(TargetRegisterInfo::isVirtualRegister(regB) && |
| 402 | ; |
| 403 | ; it failed when MipsDAGToDAGISel::ReplaceUsesWithZeroReg replaced an |
| 404 | ; operand of an atomic instruction with register $zero. |
| 405 | @a = external global i32 |
| 406 | |
| 407 | define i32 @zeroreg() nounwind { |
| 408 | entry: |
Tim Northover | 420a216 | 2014-06-13 14:24:07 +0000 | [diff] [blame] | 409 | %pair0 = cmpxchg i32* @a, i32 1, i32 0 seq_cst seq_cst |
| 410 | %0 = extractvalue { i32, i1 } %pair0, 0 |
Akira Hatanaka | 0661b81 | 2012-05-11 23:22:18 +0000 | [diff] [blame] | 411 | %1 = icmp eq i32 %0, 1 |
| 412 | %conv = zext i1 %1 to i32 |
| 413 | ret i32 %conv |
| 414 | } |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 415 | |
| 416 | ; Check that MIPS32R6 has the correct offset range. |
| 417 | ; FIXME: At the moment, we don't seem to do addr+offset for any atomic load/store. |
| 418 | define i32 @AtomicLoadAdd32_OffGt9Bit(i32 %incr) nounwind { |
| 419 | entry: |
| 420 | %0 = atomicrmw add i32* getelementptr(i32* @x, i32 256), i32 %incr monotonic |
| 421 | ret i32 %0 |
| 422 | |
| 423 | ; ALL-LABEL: AtomicLoadAdd32_OffGt9Bit: |
| 424 | |
| 425 | ; MIPS32-ANY: lw $[[R0:[0-9]+]], %got(x) |
| 426 | ; MIPS64-ANY: ld $[[R0:[0-9]+]], %got_disp(x)( |
| 427 | |
| 428 | ; ALL: addiu $[[PTR:[0-9]+]], $[[R0]], 1024 |
| 429 | ; ALL: $[[BB0:[A-Z_0-9]+]]: |
| 430 | ; ALL: ll $[[R1:[0-9]+]], 0($[[PTR]]) |
| 431 | ; ALL: addu $[[R2:[0-9]+]], $[[R1]], $4 |
| 432 | ; ALL: sc $[[R2]], 0($[[PTR]]) |
| 433 | ; ALL: beqz $[[R2]], $[[BB0]] |
| 434 | } |