1; RUN: llc < %s -O0 -march=x86-64 -mcpu=corei7 -verify-machineinstrs | FileCheck %s --check-prefix X64 2; RUN: llc < %s -O0 -march=x86 -mcpu=corei7 -verify-machineinstrs | FileCheck %s --check-prefix X32 3 4@sc8 = external global i8 5 6define void @atomic_fetch_add8() nounwind { 7; X64-LABEL: atomic_fetch_add8: 8; X32-LABEL: atomic_fetch_add8: 9entry: 10; 32-bit 11 %t1 = atomicrmw add i8* @sc8, i8 1 acquire 12; X64: lock 13; X64: incb 14; X32: lock 15; X32: incb 16 %t2 = atomicrmw add i8* @sc8, i8 3 acquire 17; X64: lock 18; X64: addb $3 19; X32: lock 20; X32: addb $3 21 %t3 = atomicrmw add i8* @sc8, i8 5 acquire 22; X64: lock 23; X64: xaddb 24; X32: lock 25; X32: xaddb 26 %t4 = atomicrmw add i8* @sc8, i8 %t3 acquire 27; X64: lock 28; X64: addb 29; X32: lock 30; X32: addb 31 ret void 32; X64: ret 33; X32: ret 34} 35 36define void @atomic_fetch_sub8() nounwind { 37; X64-LABEL: atomic_fetch_sub8: 38; X32-LABEL: atomic_fetch_sub8: 39 %t1 = atomicrmw sub i8* @sc8, i8 1 acquire 40; X64: lock 41; X64: decb 42; X32: lock 43; X32: decb 44 %t2 = atomicrmw sub i8* @sc8, i8 3 acquire 45; X64: lock 46; X64: subb $3 47; X32: lock 48; X32: subb $3 49 %t3 = atomicrmw sub i8* @sc8, i8 5 acquire 50; X64: lock 51; X64: xaddb 52; X32: lock 53; X32: xaddb 54 %t4 = atomicrmw sub i8* @sc8, i8 %t3 acquire 55; X64: lock 56; X64: subb 57; X32: lock 58; X32: subb 59 ret void 60; X64: ret 61; X32: ret 62} 63 64define void @atomic_fetch_and8() nounwind { 65; X64-LABEL: atomic_fetch_and8: 66; X32-LABEL: atomic_fetch_and8: 67 %t1 = atomicrmw and i8* @sc8, i8 3 acquire 68; X64: lock 69; X64: andb $3 70; X32: lock 71; X32: andb $3 72 %t2 = atomicrmw and i8* @sc8, i8 5 acquire 73; X64: andb 74; X64: lock 75; X64: cmpxchgb 76; X32: andb 77; X32: lock 78; X32: cmpxchgb 79 %t3 = atomicrmw and i8* @sc8, i8 %t2 acquire 80; X64: lock 81; X64: andb 82; X32: lock 83; X32: andb 84 ret void 85; X64: ret 86; X32: ret 87} 88 89define void @atomic_fetch_or8() nounwind { 90; X64-LABEL: atomic_fetch_or8: 91; X32-LABEL: atomic_fetch_or8: 92 %t1 = atomicrmw or i8* @sc8, i8 3 acquire 93; X64: lock 94; X64: orb $3 95; X32: lock 96; X32: orb $3 97 %t2 = atomicrmw or i8* @sc8, i8 5 acquire 98; X64: orb 99; X64: lock 100; X64: cmpxchgb 101; X32: orb 102; X32: lock 103; X32: cmpxchgb 104 %t3 = atomicrmw or i8* @sc8, i8 %t2 acquire 105; X64: lock 106; X64: orb 107; X32: lock 108; X32: orb 109 ret void 110; X64: ret 111; X32: ret 112} 113 114define void @atomic_fetch_xor8() nounwind { 115; X64-LABEL: atomic_fetch_xor8: 116; X32-LABEL: atomic_fetch_xor8: 117 %t1 = atomicrmw xor i8* @sc8, i8 3 acquire 118; X64: lock 119; X64: xorb $3 120; X32: lock 121; X32: xorb $3 122 %t2 = atomicrmw xor i8* @sc8, i8 5 acquire 123; X64: xorb 124; X64: lock 125; X64: cmpxchgb 126; X32: xorb 127; X32: lock 128; X32: cmpxchgb 129 %t3 = atomicrmw xor i8* @sc8, i8 %t2 acquire 130; X64: lock 131; X64: xorb 132; X32: lock 133; X32: xorb 134 ret void 135; X64: ret 136; X32: ret 137} 138 139define void @atomic_fetch_nand8(i8 %x) nounwind { 140; X64-LABEL: atomic_fetch_nand8: 141; X32-LABEL: atomic_fetch_nand8: 142 %t1 = atomicrmw nand i8* @sc8, i8 %x acquire 143; X64: andb 144; X64: notb 145; X64: lock 146; X64: cmpxchgb 147; X32: andb 148; X32: notb 149; X32: lock 150; X32: cmpxchgb 151 ret void 152; X64: ret 153; X32: ret 154} 155 156define void @atomic_fetch_max8(i8 %x) nounwind { 157; X64-LABEL: atomic_fetch_max8: 158; X32-LABEL: atomic_fetch_max8: 159 %t1 = atomicrmw max i8* @sc8, i8 %x acquire 160; X64: movsbl 161; X64: movsbl 162; X64: subl 163; X64: lock 164; X64: cmpxchgb 165 166; X32: movsbl 167; X32: movsbl 168; X32: subl 169; X32: lock 170; X32: cmpxchgb 171 ret void 172; X64: ret 173; X32: ret 174} 175 176define void @atomic_fetch_min8(i8 %x) nounwind { 177; X64-LABEL: atomic_fetch_min8: 178; X32-LABEL: atomic_fetch_min8: 179 %t1 = atomicrmw min i8* @sc8, i8 %x acquire 180; X64: movsbl 181; X64: movsbl 182; X64: subl 183; X64: lock 184; X64: cmpxchgb 185 186; X32: movsbl 187; X32: movsbl 188; X32: subl 189; X32: lock 190; X32: cmpxchgb 191 ret void 192; X64: ret 193; X32: ret 194} 195 196define void @atomic_fetch_umax8(i8 %x) nounwind { 197; X64-LABEL: atomic_fetch_umax8: 198; X32-LABEL: atomic_fetch_umax8: 199 %t1 = atomicrmw umax i8* @sc8, i8 %x acquire 200; X64: movzbl 201; X64: movzbl 202; X64: subl 203; X64: lock 204; X64: cmpxchgb 205 206; X32: movzbl 207; X32: movzbl 208; X32: subl 209; X32: lock 210; X32: cmpxchgb 211 ret void 212; X64: ret 213; X32: ret 214} 215 216define void @atomic_fetch_umin8(i8 %x) nounwind { 217; X64-LABEL: atomic_fetch_umin8: 218; X32-LABEL: atomic_fetch_umin8: 219 %t1 = atomicrmw umin i8* @sc8, i8 %x acquire 220; X64: movzbl 221; X64: movzbl 222; X64: subl 223; X64: lock 224; X64: cmpxchgb 225 226; X32: movzbl 227; X32: movzbl 228; X32: subl 229; X32: lock 230; X32: cmpxchgb 231 ret void 232; X64: ret 233; X32: ret 234} 235 236define void @atomic_fetch_cmpxchg8() nounwind { 237; X64-LABEL: atomic_fetch_cmpxchg8: 238; X32-LABEL: atomic_fetch_cmpxchg8: 239 %t1 = cmpxchg i8* @sc8, i8 0, i8 1 acquire acquire 240; X64: lock 241; X64: cmpxchgb 242; X32: lock 243; X32: cmpxchgb 244 ret void 245; X64: ret 246; X32: ret 247} 248 249define void @atomic_fetch_store8(i8 %x) nounwind { 250; X64-LABEL: atomic_fetch_store8: 251; X32-LABEL: atomic_fetch_store8: 252 store atomic i8 %x, i8* @sc8 release, align 4 253; X64-NOT: lock 254; X64: movb 255; X32-NOT: lock 256; X32: movb 257 ret void 258; X64: ret 259; X32: ret 260} 261 262define void @atomic_fetch_swap8(i8 %x) nounwind { 263; X64-LABEL: atomic_fetch_swap8: 264; X32-LABEL: atomic_fetch_swap8: 265 %t1 = atomicrmw xchg i8* @sc8, i8 %x acquire 266; X64-NOT: lock 267; X64: xchgb 268; X32-NOT: lock 269; X32: xchgb 270 ret void 271; X64: ret 272; X32: ret 273} 274