1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -mtriple=x86_64-unknown-unknown -mcpu=corei7 -verify-machineinstrs -show-mc-encoding | FileCheck %s --check-prefix X64 2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -mtriple=i386-unknown-unknown -mcpu=corei7 -verify-machineinstrs | FileCheck %s --check-prefix X32 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker@sc16 = external global i16 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_add16() nounwind { 7*9880d681SAndroid Build Coastguard Worker; X64-LABEL: atomic_fetch_add16 8*9880d681SAndroid Build Coastguard Worker; X32-LABEL: atomic_fetch_add16 9*9880d681SAndroid Build Coastguard Workerentry: 10*9880d681SAndroid Build Coastguard Worker; 32-bit 11*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw add i16* @sc16, i16 1 acquire 12*9880d681SAndroid Build Coastguard Worker; X64: lock 13*9880d681SAndroid Build Coastguard Worker; X64: incw 14*9880d681SAndroid Build Coastguard Worker; X32: lock 15*9880d681SAndroid Build Coastguard Worker; X32: incw 16*9880d681SAndroid Build Coastguard Worker %t2 = atomicrmw add i16* @sc16, i16 3 acquire 17*9880d681SAndroid Build Coastguard Worker; X64: lock 18*9880d681SAndroid Build Coastguard Worker; X64: addw $3, {{.*}} # encoding: [0x66,0xf0 19*9880d681SAndroid Build Coastguard Worker; X32: lock 20*9880d681SAndroid Build Coastguard Worker; X32: addw $3 21*9880d681SAndroid Build Coastguard Worker %t3 = atomicrmw add i16* @sc16, i16 5 acquire 22*9880d681SAndroid Build Coastguard Worker; X64: lock 23*9880d681SAndroid Build Coastguard Worker; X64: xaddw {{.*}} # encoding: [0x66,0xf0 24*9880d681SAndroid Build Coastguard Worker; X32: lock 25*9880d681SAndroid Build Coastguard Worker; X32: xaddw 26*9880d681SAndroid Build Coastguard Worker %t4 = atomicrmw add i16* @sc16, i16 %t3 acquire 27*9880d681SAndroid Build Coastguard Worker; X64: lock 28*9880d681SAndroid Build Coastguard Worker; X64: addw {{.*}} # encoding: [0x66,0xf0 29*9880d681SAndroid Build Coastguard Worker; X32: lock 30*9880d681SAndroid Build Coastguard Worker; X32: addw 31*9880d681SAndroid Build Coastguard Worker ret void 32*9880d681SAndroid Build Coastguard Worker; X64: ret 33*9880d681SAndroid Build Coastguard Worker; X32: ret 34*9880d681SAndroid Build Coastguard Worker} 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_sub16() nounwind { 37*9880d681SAndroid Build Coastguard Worker; X64-LABEL: atomic_fetch_sub16 38*9880d681SAndroid Build Coastguard Worker; X32-LABEL: atomic_fetch_sub16 39*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw sub i16* @sc16, i16 1 acquire 40*9880d681SAndroid Build Coastguard Worker; X64: lock 41*9880d681SAndroid Build Coastguard Worker; X64: decw 42*9880d681SAndroid Build Coastguard Worker; X32: lock 43*9880d681SAndroid Build Coastguard Worker; X32: decw 44*9880d681SAndroid Build Coastguard Worker %t2 = atomicrmw sub i16* @sc16, i16 3 acquire 45*9880d681SAndroid Build Coastguard Worker; X64: lock 46*9880d681SAndroid Build Coastguard Worker; X64: subw $3, {{.*}} # encoding: [0x66,0xf0 47*9880d681SAndroid Build Coastguard Worker; X32: lock 48*9880d681SAndroid Build Coastguard Worker; X32: subw $3 49*9880d681SAndroid Build Coastguard Worker %t3 = atomicrmw sub i16* @sc16, i16 5 acquire 50*9880d681SAndroid Build Coastguard Worker; X64: lock 51*9880d681SAndroid Build Coastguard Worker; X64: xaddw {{.*}} # encoding: [0x66,0xf0 52*9880d681SAndroid Build Coastguard Worker; X32: lock 53*9880d681SAndroid Build Coastguard Worker; X32: xaddw 54*9880d681SAndroid Build Coastguard Worker %t4 = atomicrmw sub i16* @sc16, i16 %t3 acquire 55*9880d681SAndroid Build Coastguard Worker; X64: lock 56*9880d681SAndroid Build Coastguard Worker; X64: subw {{.*}} # encoding: [0x66,0xf0 57*9880d681SAndroid Build Coastguard Worker; X32: lock 58*9880d681SAndroid Build Coastguard Worker; X32: subw 59*9880d681SAndroid Build Coastguard Worker ret void 60*9880d681SAndroid Build Coastguard Worker; X64: ret 61*9880d681SAndroid Build Coastguard Worker; X32: ret 62*9880d681SAndroid Build Coastguard Worker} 63*9880d681SAndroid Build Coastguard Worker 64*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_and16() nounwind { 65*9880d681SAndroid Build Coastguard Worker; X64-LABEL: atomic_fetch_and16 66*9880d681SAndroid Build Coastguard Worker; X32-LABEL: atomic_fetch_and16 67*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw and i16* @sc16, i16 3 acquire 68*9880d681SAndroid Build Coastguard Worker; X64: lock 69*9880d681SAndroid Build Coastguard Worker; X64: andw $3, {{.*}} # encoding: [0x66,0xf0 70*9880d681SAndroid Build Coastguard Worker; X32: lock 71*9880d681SAndroid Build Coastguard Worker; X32: andw $3 72*9880d681SAndroid Build Coastguard Worker %t2 = atomicrmw and i16* @sc16, i16 5 acquire 73*9880d681SAndroid Build Coastguard Worker; X64: andl 74*9880d681SAndroid Build Coastguard Worker; X64: lock 75*9880d681SAndroid Build Coastguard Worker; X64: cmpxchgw 76*9880d681SAndroid Build Coastguard Worker; X32: andl 77*9880d681SAndroid Build Coastguard Worker; X32: lock 78*9880d681SAndroid Build Coastguard Worker; X32: cmpxchgw 79*9880d681SAndroid Build Coastguard Worker %t3 = atomicrmw and i16* @sc16, i16 %t2 acquire 80*9880d681SAndroid Build Coastguard Worker; X64: lock 81*9880d681SAndroid Build Coastguard Worker; X64: andw {{.*}} # encoding: [0x66,0xf0 82*9880d681SAndroid Build Coastguard Worker; X32: lock 83*9880d681SAndroid Build Coastguard Worker; X32: andw 84*9880d681SAndroid Build Coastguard Worker ret void 85*9880d681SAndroid Build Coastguard Worker; X64: ret 86*9880d681SAndroid Build Coastguard Worker; X32: ret 87*9880d681SAndroid Build Coastguard Worker} 88*9880d681SAndroid Build Coastguard Worker 89*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_or16() nounwind { 90*9880d681SAndroid Build Coastguard Worker; X64-LABEL: atomic_fetch_or16 91*9880d681SAndroid Build Coastguard Worker; X32-LABEL: atomic_fetch_or16 92*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw or i16* @sc16, i16 3 acquire 93*9880d681SAndroid Build Coastguard Worker; X64: lock 94*9880d681SAndroid Build Coastguard Worker; X64: orw $3, {{.*}} # encoding: [0x66,0xf0 95*9880d681SAndroid Build Coastguard Worker; X32: lock 96*9880d681SAndroid Build Coastguard Worker; X32: orw $3 97*9880d681SAndroid Build Coastguard Worker %t2 = atomicrmw or i16* @sc16, i16 5 acquire 98*9880d681SAndroid Build Coastguard Worker; X64: orl 99*9880d681SAndroid Build Coastguard Worker; X64: lock 100*9880d681SAndroid Build Coastguard Worker; X64: cmpxchgw 101*9880d681SAndroid Build Coastguard Worker; X32: orl 102*9880d681SAndroid Build Coastguard Worker; X32: lock 103*9880d681SAndroid Build Coastguard Worker; X32: cmpxchgw 104*9880d681SAndroid Build Coastguard Worker %t3 = atomicrmw or i16* @sc16, i16 %t2 acquire 105*9880d681SAndroid Build Coastguard Worker; X64: lock 106*9880d681SAndroid Build Coastguard Worker; X64: orw {{.*}} # encoding: [0x66,0xf0 107*9880d681SAndroid Build Coastguard Worker; X32: lock 108*9880d681SAndroid Build Coastguard Worker; X32: orw 109*9880d681SAndroid Build Coastguard Worker ret void 110*9880d681SAndroid Build Coastguard Worker; X64: ret 111*9880d681SAndroid Build Coastguard Worker; X32: ret 112*9880d681SAndroid Build Coastguard Worker} 113*9880d681SAndroid Build Coastguard Worker 114*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_xor16() nounwind { 115*9880d681SAndroid Build Coastguard Worker; X64-LABEL: atomic_fetch_xor16 116*9880d681SAndroid Build Coastguard Worker; X32-LABEL: atomic_fetch_xor16 117*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw xor i16* @sc16, i16 3 acquire 118*9880d681SAndroid Build Coastguard Worker; X64: lock 119*9880d681SAndroid Build Coastguard Worker; X64: xorw $3, {{.*}} # encoding: [0x66,0xf0 120*9880d681SAndroid Build Coastguard Worker; X32: lock 121*9880d681SAndroid Build Coastguard Worker; X32: xorw $3 122*9880d681SAndroid Build Coastguard Worker %t2 = atomicrmw xor i16* @sc16, i16 5 acquire 123*9880d681SAndroid Build Coastguard Worker; X64: xorl 124*9880d681SAndroid Build Coastguard Worker; X64: lock 125*9880d681SAndroid Build Coastguard Worker; X64: cmpxchgw 126*9880d681SAndroid Build Coastguard Worker; X32: xorl 127*9880d681SAndroid Build Coastguard Worker; X32: lock 128*9880d681SAndroid Build Coastguard Worker; X32: cmpxchgw 129*9880d681SAndroid Build Coastguard Worker %t3 = atomicrmw xor i16* @sc16, i16 %t2 acquire 130*9880d681SAndroid Build Coastguard Worker; X64: lock 131*9880d681SAndroid Build Coastguard Worker; X64: xorw {{.*}} # encoding: [0x66,0xf0 132*9880d681SAndroid Build Coastguard Worker; X32: lock 133*9880d681SAndroid Build Coastguard Worker; X32: xorw 134*9880d681SAndroid Build Coastguard Worker ret void 135*9880d681SAndroid Build Coastguard Worker; X64: ret 136*9880d681SAndroid Build Coastguard Worker; X32: ret 137*9880d681SAndroid Build Coastguard Worker} 138*9880d681SAndroid Build Coastguard Worker 139*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_nand16(i16 %x) nounwind { 140*9880d681SAndroid Build Coastguard Worker; X64-LABEL: atomic_fetch_nand16 141*9880d681SAndroid Build Coastguard Worker; X32-LABEL: atomic_fetch_nand16 142*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw nand i16* @sc16, i16 %x acquire 143*9880d681SAndroid Build Coastguard Worker; X64: andl 144*9880d681SAndroid Build Coastguard Worker; X64: notl 145*9880d681SAndroid Build Coastguard Worker; X64: lock 146*9880d681SAndroid Build Coastguard Worker; X64: cmpxchgw 147*9880d681SAndroid Build Coastguard Worker; X32: andl 148*9880d681SAndroid Build Coastguard Worker; X32: notl 149*9880d681SAndroid Build Coastguard Worker; X32: lock 150*9880d681SAndroid Build Coastguard Worker; X32: cmpxchgw 151*9880d681SAndroid Build Coastguard Worker ret void 152*9880d681SAndroid Build Coastguard Worker; X64: ret 153*9880d681SAndroid Build Coastguard Worker; X32: ret 154*9880d681SAndroid Build Coastguard Worker} 155*9880d681SAndroid Build Coastguard Worker 156*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_max16(i16 %x) nounwind { 157*9880d681SAndroid Build Coastguard Worker; X64-LABEL: atomic_fetch_max16 158*9880d681SAndroid Build Coastguard Worker; X32-LABEL: atomic_fetch_max16 159*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw max i16* @sc16, i16 %x acquire 160*9880d681SAndroid Build Coastguard Worker; X64: movw 161*9880d681SAndroid Build Coastguard Worker; X64: movw 162*9880d681SAndroid Build Coastguard Worker; X64: subw 163*9880d681SAndroid Build Coastguard Worker; X64: cmov 164*9880d681SAndroid Build Coastguard Worker; X64: lock 165*9880d681SAndroid Build Coastguard Worker; X64: cmpxchgw 166*9880d681SAndroid Build Coastguard Worker 167*9880d681SAndroid Build Coastguard Worker; X32: movw 168*9880d681SAndroid Build Coastguard Worker; X32: movw 169*9880d681SAndroid Build Coastguard Worker; X32: subw 170*9880d681SAndroid Build Coastguard Worker; X32: cmov 171*9880d681SAndroid Build Coastguard Worker; X32: lock 172*9880d681SAndroid Build Coastguard Worker; X32: cmpxchgw 173*9880d681SAndroid Build Coastguard Worker ret void 174*9880d681SAndroid Build Coastguard Worker; X64: ret 175*9880d681SAndroid Build Coastguard Worker; X32: ret 176*9880d681SAndroid Build Coastguard Worker} 177*9880d681SAndroid Build Coastguard Worker 178*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_min16(i16 %x) nounwind { 179*9880d681SAndroid Build Coastguard Worker; X64-LABEL: atomic_fetch_min16 180*9880d681SAndroid Build Coastguard Worker; X32-LABEL: atomic_fetch_min16 181*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw min i16* @sc16, i16 %x acquire 182*9880d681SAndroid Build Coastguard Worker; X64: movw 183*9880d681SAndroid Build Coastguard Worker; X64: movw 184*9880d681SAndroid Build Coastguard Worker; X64: subw 185*9880d681SAndroid Build Coastguard Worker; X64: cmov 186*9880d681SAndroid Build Coastguard Worker; X64: lock 187*9880d681SAndroid Build Coastguard Worker; X64: cmpxchgw 188*9880d681SAndroid Build Coastguard Worker 189*9880d681SAndroid Build Coastguard Worker; X32: movw 190*9880d681SAndroid Build Coastguard Worker; X32: movw 191*9880d681SAndroid Build Coastguard Worker; X32: subw 192*9880d681SAndroid Build Coastguard Worker; X32: cmov 193*9880d681SAndroid Build Coastguard Worker; X32: lock 194*9880d681SAndroid Build Coastguard Worker; X32: cmpxchgw 195*9880d681SAndroid Build Coastguard Worker ret void 196*9880d681SAndroid Build Coastguard Worker; X64: ret 197*9880d681SAndroid Build Coastguard Worker; X32: ret 198*9880d681SAndroid Build Coastguard Worker} 199*9880d681SAndroid Build Coastguard Worker 200*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_umax16(i16 %x) nounwind { 201*9880d681SAndroid Build Coastguard Worker; X64-LABEL: atomic_fetch_umax16 202*9880d681SAndroid Build Coastguard Worker; X32-LABEL: atomic_fetch_umax16 203*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw umax i16* @sc16, i16 %x acquire 204*9880d681SAndroid Build Coastguard Worker; X64: movw 205*9880d681SAndroid Build Coastguard Worker; X64: movw 206*9880d681SAndroid Build Coastguard Worker; X64: subw 207*9880d681SAndroid Build Coastguard Worker; X64: cmov 208*9880d681SAndroid Build Coastguard Worker; X64: lock 209*9880d681SAndroid Build Coastguard Worker; X64: cmpxchgw 210*9880d681SAndroid Build Coastguard Worker 211*9880d681SAndroid Build Coastguard Worker; X32: movw 212*9880d681SAndroid Build Coastguard Worker; X32: movw 213*9880d681SAndroid Build Coastguard Worker; X32: subw 214*9880d681SAndroid Build Coastguard Worker; X32: cmov 215*9880d681SAndroid Build Coastguard Worker; X32: lock 216*9880d681SAndroid Build Coastguard Worker; X32: cmpxchgw 217*9880d681SAndroid Build Coastguard Worker ret void 218*9880d681SAndroid Build Coastguard Worker; X64: ret 219*9880d681SAndroid Build Coastguard Worker; X32: ret 220*9880d681SAndroid Build Coastguard Worker} 221*9880d681SAndroid Build Coastguard Worker 222*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_umin16(i16 %x) nounwind { 223*9880d681SAndroid Build Coastguard Worker; X64-LABEL: atomic_fetch_umin16 224*9880d681SAndroid Build Coastguard Worker; X32-LABEL: atomic_fetch_umin16 225*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw umin i16* @sc16, i16 %x acquire 226*9880d681SAndroid Build Coastguard Worker; X64: movw 227*9880d681SAndroid Build Coastguard Worker; X64: movw 228*9880d681SAndroid Build Coastguard Worker; X64: subw 229*9880d681SAndroid Build Coastguard Worker; X64: cmov 230*9880d681SAndroid Build Coastguard Worker; X64: lock 231*9880d681SAndroid Build Coastguard Worker; X64: cmpxchgw 232*9880d681SAndroid Build Coastguard Worker 233*9880d681SAndroid Build Coastguard Worker; X32: movw 234*9880d681SAndroid Build Coastguard Worker; X32: movw 235*9880d681SAndroid Build Coastguard Worker; X32: subw 236*9880d681SAndroid Build Coastguard Worker; X32: cmov 237*9880d681SAndroid Build Coastguard Worker; X32: lock 238*9880d681SAndroid Build Coastguard Worker; X32: cmpxchgw 239*9880d681SAndroid Build Coastguard Worker ret void 240*9880d681SAndroid Build Coastguard Worker; X64: ret 241*9880d681SAndroid Build Coastguard Worker; X32: ret 242*9880d681SAndroid Build Coastguard Worker} 243*9880d681SAndroid Build Coastguard Worker 244*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_cmpxchg16() nounwind { 245*9880d681SAndroid Build Coastguard Worker %t1 = cmpxchg i16* @sc16, i16 0, i16 1 acquire acquire 246*9880d681SAndroid Build Coastguard Worker; X64: lock 247*9880d681SAndroid Build Coastguard Worker; X64: cmpxchgw 248*9880d681SAndroid Build Coastguard Worker; X32: lock 249*9880d681SAndroid Build Coastguard Worker; X32: cmpxchgw 250*9880d681SAndroid Build Coastguard Worker ret void 251*9880d681SAndroid Build Coastguard Worker; X64: ret 252*9880d681SAndroid Build Coastguard Worker; X32: ret 253*9880d681SAndroid Build Coastguard Worker} 254*9880d681SAndroid Build Coastguard Worker 255*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_store16(i16 %x) nounwind { 256*9880d681SAndroid Build Coastguard Worker store atomic i16 %x, i16* @sc16 release, align 4 257*9880d681SAndroid Build Coastguard Worker; X64-NOT: lock 258*9880d681SAndroid Build Coastguard Worker; X64: movw 259*9880d681SAndroid Build Coastguard Worker; X32-NOT: lock 260*9880d681SAndroid Build Coastguard Worker; X32: movw 261*9880d681SAndroid Build Coastguard Worker ret void 262*9880d681SAndroid Build Coastguard Worker; X64: ret 263*9880d681SAndroid Build Coastguard Worker; X32: ret 264*9880d681SAndroid Build Coastguard Worker} 265*9880d681SAndroid Build Coastguard Worker 266*9880d681SAndroid Build Coastguard Workerdefine void @atomic_fetch_swap16(i16 %x) nounwind { 267*9880d681SAndroid Build Coastguard Worker %t1 = atomicrmw xchg i16* @sc16, i16 %x acquire 268*9880d681SAndroid Build Coastguard Worker; X64-NOT: lock 269*9880d681SAndroid Build Coastguard Worker; X64: xchgw 270*9880d681SAndroid Build Coastguard Worker; X32-NOT: lock 271*9880d681SAndroid Build Coastguard Worker; X32: xchgw 272*9880d681SAndroid Build Coastguard Worker ret void 273*9880d681SAndroid Build Coastguard Worker; X64: ret 274*9880d681SAndroid Build Coastguard Worker; X32: ret 275*9880d681SAndroid Build Coastguard Worker} 276