atomics.ll 14.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --force-update
; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc-unknown-linux-gnu -verify-machineinstrs  -ppc-asm-full-reg-names | FileCheck %s --check-prefix=CHECK --check-prefix=PPC32
; This is already checked for in Atomics-64.ll
; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu  -ppc-asm-full-reg-names | FileCheck %s --check-prefix=CHECK --check-prefix=PPC64

; FIXME: we don't currently check for the operations themselves with CHECK-NEXT,
;   because they are implemented in a very messy way with lwarx/stwcx.
;   It should be fixed soon in another patch.

; We first check loads, for all sizes from i8 to i64.
; We also vary orderings to check for barriers.
define i8 @load_i8_unordered(i8* %mem) {
; CHECK-LABEL: load_i8_unordered:
; CHECK:       # %bb.0:
; CHECK-NEXT:    lbz r3, 0(r3)
; CHECK-NEXT:    blr
  %val = load atomic i8, i8* %mem unordered, align 1
  ret i8 %val
}
define i16 @load_i16_monotonic(i16* %mem) {
; CHECK-LABEL: load_i16_monotonic:
; CHECK:       # %bb.0:
; CHECK-NEXT:    lhz r3, 0(r3)
; CHECK-NEXT:    blr
  %val = load atomic i16, i16* %mem monotonic, align 2
  ret i16 %val
}
define i32 @load_i32_acquire(i32* %mem) {
; PPC32-LABEL: load_i32_acquire:
; PPC32:       # %bb.0:
; PPC32-NEXT:    lwz r3, 0(r3)
; PPC32-NEXT:    lwsync
; PPC32-NEXT:    blr
;
; PPC64-LABEL: load_i32_acquire:
; PPC64:       # %bb.0:
; PPC64-NEXT:    lwz r3, 0(r3)
; PPC64-NEXT:    cmpd cr7, r3, r3
; PPC64-NEXT:    bne- cr7, .+4
; PPC64-NEXT:    isync
; PPC64-NEXT:    blr
  %val = load atomic i32, i32* %mem acquire, align 4
; CHECK-PPC32: lwsync
; CHECK-PPC64: cmpw [[CR:cr[0-9]+]], [[VAL]], [[VAL]]
; CHECK-PPC64: bne- [[CR]], .+4
; CHECK-PPC64: isync
  ret i32 %val
}
define i64 @load_i64_seq_cst(i64* %mem) {
; PPC32-LABEL: load_i64_seq_cst:
; PPC32:       # %bb.0:
; PPC32-NEXT:    mflr r0
; PPC32-NEXT:    stw r0, 4(r1)
; PPC32-NEXT:    stwu r1, -16(r1)
; PPC32-NEXT:    .cfi_def_cfa_offset 16
; PPC32-NEXT:    .cfi_offset lr, 4
; PPC32-NEXT:    li r4, 5
; PPC32-NEXT:    bl __atomic_load_8
; PPC32-NEXT:    lwz r0, 20(r1)
; PPC32-NEXT:    addi r1, r1, 16
; PPC32-NEXT:    mtlr r0
; PPC32-NEXT:    blr
;
; PPC64-LABEL: load_i64_seq_cst:
; PPC64:       # %bb.0:
; PPC64-NEXT:    sync
; PPC64-NEXT:    ld r3, 0(r3)
; PPC64-NEXT:    cmpd cr7, r3, r3
; PPC64-NEXT:    bne- cr7, .+4
; PPC64-NEXT:    isync
; PPC64-NEXT:    blr
  %val = load atomic i64, i64* %mem seq_cst, align 8
; CHECK-PPC32: lwsync
; CHECK-PPC64: cmpw [[CR:cr[0-9]+]], [[VAL]], [[VAL]]
; CHECK-PPC64: bne- [[CR]], .+4
; CHECK-PPC64: isync
  ret i64 %val
}

; Stores
define void @store_i8_unordered(i8* %mem) {
; CHECK-LABEL: store_i8_unordered:
; CHECK:       # %bb.0:
; CHECK-NEXT:    li r4, 42
; CHECK-NEXT:    stb r4, 0(r3)
; CHECK-NEXT:    blr
  store atomic i8 42, i8* %mem unordered, align 1
  ret void
}
define void @store_i16_monotonic(i16* %mem) {
; CHECK-LABEL: store_i16_monotonic:
; CHECK:       # %bb.0:
; CHECK-NEXT:    li r4, 42
; CHECK-NEXT:    sth r4, 0(r3)
; CHECK-NEXT:    blr
  store atomic i16 42, i16* %mem monotonic, align 2
  ret void
}
define void @store_i32_release(i32* %mem) {
; CHECK-LABEL: store_i32_release:
; CHECK:       # %bb.0:
; CHECK-NEXT:    li r4, 42
; CHECK-NEXT:    lwsync
; CHECK-NEXT:    stw r4, 0(r3)
; CHECK-NEXT:    blr
  store atomic i32 42, i32* %mem release, align 4
  ret void
}
define void @store_i64_seq_cst(i64* %mem) {
; PPC32-LABEL: store_i64_seq_cst:
; PPC32:       # %bb.0:
; PPC32-NEXT:    mflr r0
; PPC32-NEXT:    stw r0, 4(r1)
; PPC32-NEXT:    stwu r1, -16(r1)
; PPC32-NEXT:    .cfi_def_cfa_offset 16
; PPC32-NEXT:    .cfi_offset lr, 4
; PPC32-NEXT:    li r5, 0
; PPC32-NEXT:    li r6, 42
; PPC32-NEXT:    li r7, 5
; PPC32-NEXT:    bl __atomic_store_8
; PPC32-NEXT:    lwz r0, 20(r1)
; PPC32-NEXT:    addi r1, r1, 16
; PPC32-NEXT:    mtlr r0
; PPC32-NEXT:    blr
;
; PPC64-LABEL: store_i64_seq_cst:
; PPC64:       # %bb.0:
; PPC64-NEXT:    li r4, 42
; PPC64-NEXT:    sync
; PPC64-NEXT:    std r4, 0(r3)
; PPC64-NEXT:    blr
  store atomic i64 42, i64* %mem seq_cst, align 8
  ret void
}

; Atomic CmpXchg
define i8 @cas_strong_i8_sc_sc(i8* %mem) {
; PPC32-LABEL: cas_strong_i8_sc_sc:
; PPC32:       # %bb.0:
; PPC32-NEXT:    rlwinm r8, r3, 3, 27, 28
; PPC32-NEXT:    li r5, 1
; PPC32-NEXT:    li r6, 0
; PPC32-NEXT:    li r7, 255
; PPC32-NEXT:    rlwinm r4, r3, 0, 0, 29
; PPC32-NEXT:    xori r3, r8, 24
; PPC32-NEXT:    slw r5, r5, r3
; PPC32-NEXT:    slw r8, r6, r3
; PPC32-NEXT:    slw r6, r7, r3
; PPC32-NEXT:    and r7, r5, r6
; PPC32-NEXT:    and r8, r8, r6
; PPC32-NEXT:    sync
; PPC32-NEXT:  .LBB8_1:
; PPC32-NEXT:    lwarx r9, 0, r4
; PPC32-NEXT:    and r5, r9, r6
; PPC32-NEXT:    cmpw r5, r8
; PPC32-NEXT:    bne cr0, .LBB8_3
; PPC32-NEXT:  # %bb.2:
; PPC32-NEXT:    andc r9, r9, r6
; PPC32-NEXT:    or r9, r9, r7
; PPC32-NEXT:    stwcx. r9, 0, r4
; PPC32-NEXT:    bne cr0, .LBB8_1
; PPC32-NEXT:    b .LBB8_4
; PPC32-NEXT:  .LBB8_3:
; PPC32-NEXT:    stwcx. r9, 0, r4
; PPC32-NEXT:  .LBB8_4:
; PPC32-NEXT:    srw r3, r5, r3
; PPC32-NEXT:    lwsync
; PPC32-NEXT:    blr
;
; PPC64-LABEL: cas_strong_i8_sc_sc:
; PPC64:       # %bb.0:
; PPC64-NEXT:    rlwinm r8, r3, 3, 27, 28
; PPC64-NEXT:    li r5, 1
; PPC64-NEXT:    li r6, 0
; PPC64-NEXT:    li r7, 255
; PPC64-NEXT:    rldicr r4, r3, 0, 61
; PPC64-NEXT:    xori r3, r8, 24
; PPC64-NEXT:    slw r5, r5, r3
; PPC64-NEXT:    slw r8, r6, r3
; PPC64-NEXT:    slw r6, r7, r3
; PPC64-NEXT:    and r7, r5, r6
; PPC64-NEXT:    and r8, r8, r6
; PPC64-NEXT:    sync
; PPC64-NEXT:  .LBB8_1:
; PPC64-NEXT:    lwarx r9, 0, r4
; PPC64-NEXT:    and r5, r9, r6
; PPC64-NEXT:    cmpw r5, r8
; PPC64-NEXT:    bne cr0, .LBB8_3
; PPC64-NEXT:  # %bb.2:
; PPC64-NEXT:    andc r9, r9, r6
; PPC64-NEXT:    or r9, r9, r7
; PPC64-NEXT:    stwcx. r9, 0, r4
; PPC64-NEXT:    bne cr0, .LBB8_1
; PPC64-NEXT:    b .LBB8_4
; PPC64-NEXT:  .LBB8_3:
; PPC64-NEXT:    stwcx. r9, 0, r4
; PPC64-NEXT:  .LBB8_4:
; PPC64-NEXT:    srw r3, r5, r3
; PPC64-NEXT:    lwsync
; PPC64-NEXT:    blr
  %val = cmpxchg i8* %mem, i8 0, i8 1 seq_cst seq_cst
  %loaded = extractvalue { i8, i1} %val, 0
  ret i8 %loaded
}
define i16 @cas_weak_i16_acquire_acquire(i16* %mem) {
; PPC32-LABEL: cas_weak_i16_acquire_acquire:
; PPC32:       # %bb.0:
; PPC32-NEXT:    li r6, 0
; PPC32-NEXT:    rlwinm r4, r3, 3, 27, 27
; PPC32-NEXT:    li r5, 1
; PPC32-NEXT:    ori r7, r6, 65535
; PPC32-NEXT:    xori r4, r4, 16
; PPC32-NEXT:    slw r8, r5, r4
; PPC32-NEXT:    slw r9, r6, r4
; PPC32-NEXT:    slw r5, r7, r4
; PPC32-NEXT:    rlwinm r3, r3, 0, 0, 29
; PPC32-NEXT:    and r6, r8, r5
; PPC32-NEXT:    and r8, r9, r5
; PPC32-NEXT:  .LBB9_1:
; PPC32-NEXT:    lwarx r9, 0, r3
; PPC32-NEXT:    and r7, r9, r5
; PPC32-NEXT:    cmpw r7, r8
; PPC32-NEXT:    bne cr0, .LBB9_3
; PPC32-NEXT:  # %bb.2:
; PPC32-NEXT:    andc r9, r9, r5
; PPC32-NEXT:    or r9, r9, r6
; PPC32-NEXT:    stwcx. r9, 0, r3
; PPC32-NEXT:    bne cr0, .LBB9_1
; PPC32-NEXT:    b .LBB9_4
; PPC32-NEXT:  .LBB9_3:
; PPC32-NEXT:    stwcx. r9, 0, r3
; PPC32-NEXT:  .LBB9_4:
; PPC32-NEXT:    srw r3, r7, r4
; PPC32-NEXT:    lwsync
; PPC32-NEXT:    blr
;
; PPC64-LABEL: cas_weak_i16_acquire_acquire:
; PPC64:       # %bb.0:
; PPC64-NEXT:    li r6, 0
; PPC64-NEXT:    rlwinm r4, r3, 3, 27, 27
; PPC64-NEXT:    li r5, 1
; PPC64-NEXT:    ori r7, r6, 65535
; PPC64-NEXT:    xori r4, r4, 16
; PPC64-NEXT:    slw r8, r5, r4
; PPC64-NEXT:    slw r9, r6, r4
; PPC64-NEXT:    slw r5, r7, r4
; PPC64-NEXT:    rldicr r3, r3, 0, 61
; PPC64-NEXT:    and r6, r8, r5
; PPC64-NEXT:    and r8, r9, r5
; PPC64-NEXT:  .LBB9_1:
; PPC64-NEXT:    lwarx r9, 0, r3
; PPC64-NEXT:    and r7, r9, r5
; PPC64-NEXT:    cmpw r7, r8
; PPC64-NEXT:    bne cr0, .LBB9_3
; PPC64-NEXT:  # %bb.2:
; PPC64-NEXT:    andc r9, r9, r5
; PPC64-NEXT:    or r9, r9, r6
; PPC64-NEXT:    stwcx. r9, 0, r3
; PPC64-NEXT:    bne cr0, .LBB9_1
; PPC64-NEXT:    b .LBB9_4
; PPC64-NEXT:  .LBB9_3:
; PPC64-NEXT:    stwcx. r9, 0, r3
; PPC64-NEXT:  .LBB9_4:
; PPC64-NEXT:    srw r3, r7, r4
; PPC64-NEXT:    lwsync
; PPC64-NEXT:    blr
  %val = cmpxchg weak i16* %mem, i16 0, i16 1 acquire acquire
  %loaded = extractvalue { i16, i1} %val, 0
  ret i16 %loaded
}
define i32 @cas_strong_i32_acqrel_acquire(i32* %mem) {
; CHECK-LABEL: cas_strong_i32_acqrel_acquire:
; CHECK:       # %bb.0:
; CHECK-NEXT:    li r5, 1
; CHECK-NEXT:    li r6, 0
; CHECK-NEXT:    lwsync
; CHECK-NEXT:  .LBB10_1:
; CHECK-NEXT:    lwarx r4, 0, r3
; CHECK-NEXT:    cmpw r6, r4
; CHECK-NEXT:    bne cr0, .LBB10_3
; CHECK-NEXT:  # %bb.2:
; CHECK-NEXT:    stwcx. r5, 0, r3
; CHECK-NEXT:    bne cr0, .LBB10_1
; CHECK-NEXT:    b .LBB10_4
; CHECK-NEXT:  .LBB10_3:
; CHECK-NEXT:    stwcx. r4, 0, r3
; CHECK-NEXT:  .LBB10_4:
; CHECK-NEXT:    mr r3, r4
; CHECK-NEXT:    lwsync
; CHECK-NEXT:    blr
  %val = cmpxchg i32* %mem, i32 0, i32 1 acq_rel acquire
  %loaded = extractvalue { i32, i1} %val, 0
  ret i32 %loaded
}
define i64 @cas_weak_i64_release_monotonic(i64* %mem) {
; PPC32-LABEL: cas_weak_i64_release_monotonic:
; PPC32:       # %bb.0:
; PPC32-NEXT:    mflr r0
; PPC32-NEXT:    stw r0, 4(r1)
; PPC32-NEXT:    stwu r1, -16(r1)
; PPC32-NEXT:    .cfi_def_cfa_offset 16
; PPC32-NEXT:    .cfi_offset lr, 4
; PPC32-NEXT:    li r4, 0
; PPC32-NEXT:    stw r4, 12(r1)
; PPC32-NEXT:    li r5, 0
; PPC32-NEXT:    stw r4, 8(r1)
; PPC32-NEXT:    addi r4, r1, 8
; PPC32-NEXT:    li r6, 1
; PPC32-NEXT:    li r7, 3
; PPC32-NEXT:    li r8, 0
; PPC32-NEXT:    bl __atomic_compare_exchange_8
; PPC32-NEXT:    lwz r4, 12(r1)
; PPC32-NEXT:    lwz r3, 8(r1)
; PPC32-NEXT:    lwz r0, 20(r1)
; PPC32-NEXT:    addi r1, r1, 16
; PPC32-NEXT:    mtlr r0
; PPC32-NEXT:    blr
;
; PPC64-LABEL: cas_weak_i64_release_monotonic:
; PPC64:       # %bb.0:
; PPC64-NEXT:    li r5, 1
; PPC64-NEXT:    li r6, 0
; PPC64-NEXT:    lwsync
; PPC64-NEXT:  .LBB11_1:
; PPC64-NEXT:    ldarx r4, 0, r3
; PPC64-NEXT:    cmpd r6, r4
; PPC64-NEXT:    bne cr0, .LBB11_4
; PPC64-NEXT:  # %bb.2:
; PPC64-NEXT:    stdcx. r5, 0, r3
; PPC64-NEXT:    bne cr0, .LBB11_1
; PPC64-NEXT:  # %bb.3:
; PPC64-NEXT:    mr r3, r4
; PPC64-NEXT:    blr
; PPC64-NEXT:  .LBB11_4:
; PPC64-NEXT:    stdcx. r4, 0, r3
; PPC64-NEXT:    mr r3, r4
; PPC64-NEXT:    blr
  %val = cmpxchg weak i64* %mem, i64 0, i64 1 release monotonic
  %loaded = extractvalue { i64, i1} %val, 0
  ret i64 %loaded
}

; AtomicRMW
define i8 @add_i8_monotonic(i8* %mem, i8 %operand) {
; PPC32-LABEL: add_i8_monotonic:
; PPC32:       # %bb.0:
; PPC32-NEXT:    rlwinm r7, r3, 3, 27, 28
; PPC32-NEXT:    li r6, 255
; PPC32-NEXT:    rlwinm r5, r3, 0, 0, 29
; PPC32-NEXT:    xori r3, r7, 24
; PPC32-NEXT:    slw r4, r4, r3
; PPC32-NEXT:    slw r6, r6, r3
; PPC32-NEXT:  .LBB12_1:
; PPC32-NEXT:    lwarx r7, 0, r5
; PPC32-NEXT:    add r8, r4, r7
; PPC32-NEXT:    andc r9, r7, r6
; PPC32-NEXT:    and r8, r8, r6
; PPC32-NEXT:    or r8, r8, r9
; PPC32-NEXT:    stwcx. r8, 0, r5
; PPC32-NEXT:    bne cr0, .LBB12_1
; PPC32-NEXT:  # %bb.2:
; PPC32-NEXT:    srw r3, r7, r3
; PPC32-NEXT:    blr
;
; PPC64-LABEL: add_i8_monotonic:
; PPC64:       # %bb.0:
; PPC64-NEXT:    rlwinm r7, r3, 3, 27, 28
; PPC64-NEXT:    li r6, 255
; PPC64-NEXT:    rldicr r5, r3, 0, 61
; PPC64-NEXT:    xori r3, r7, 24
; PPC64-NEXT:    slw r4, r4, r3
; PPC64-NEXT:    slw r6, r6, r3
; PPC64-NEXT:  .LBB12_1:
; PPC64-NEXT:    lwarx r7, 0, r5
; PPC64-NEXT:    add r8, r4, r7
; PPC64-NEXT:    andc r9, r7, r6
; PPC64-NEXT:    and r8, r8, r6
; PPC64-NEXT:    or r8, r8, r9
; PPC64-NEXT:    stwcx. r8, 0, r5
; PPC64-NEXT:    bne cr0, .LBB12_1
; PPC64-NEXT:  # %bb.2:
; PPC64-NEXT:    srw r3, r7, r3
; PPC64-NEXT:    blr
  %val = atomicrmw add i8* %mem, i8 %operand monotonic
  ret i8 %val
}
define i16 @xor_i16_seq_cst(i16* %mem, i16 %operand) {
; PPC32-LABEL: xor_i16_seq_cst:
; PPC32:       # %bb.0:
; PPC32-NEXT:    li r6, 0
; PPC32-NEXT:    rlwinm r7, r3, 3, 27, 27
; PPC32-NEXT:    rlwinm r5, r3, 0, 0, 29
; PPC32-NEXT:    ori r6, r6, 65535
; PPC32-NEXT:    xori r3, r7, 16
; PPC32-NEXT:    slw r4, r4, r3
; PPC32-NEXT:    slw r6, r6, r3
; PPC32-NEXT:    sync
; PPC32-NEXT:  .LBB13_1:
; PPC32-NEXT:    lwarx r7, 0, r5
; PPC32-NEXT:    xor r8, r4, r7
; PPC32-NEXT:    andc r9, r7, r6
; PPC32-NEXT:    and r8, r8, r6
; PPC32-NEXT:    or r8, r8, r9
; PPC32-NEXT:    stwcx. r8, 0, r5
; PPC32-NEXT:    bne cr0, .LBB13_1
; PPC32-NEXT:  # %bb.2:
; PPC32-NEXT:    srw r3, r7, r3
; PPC32-NEXT:    lwsync
; PPC32-NEXT:    blr
;
; PPC64-LABEL: xor_i16_seq_cst:
; PPC64:       # %bb.0:
; PPC64-NEXT:    li r6, 0
; PPC64-NEXT:    rlwinm r7, r3, 3, 27, 27
; PPC64-NEXT:    rldicr r5, r3, 0, 61
; PPC64-NEXT:    ori r6, r6, 65535
; PPC64-NEXT:    xori r3, r7, 16
; PPC64-NEXT:    slw r4, r4, r3
; PPC64-NEXT:    slw r6, r6, r3
; PPC64-NEXT:    sync
; PPC64-NEXT:  .LBB13_1:
; PPC64-NEXT:    lwarx r7, 0, r5
; PPC64-NEXT:    xor r8, r4, r7
; PPC64-NEXT:    andc r9, r7, r6
; PPC64-NEXT:    and r8, r8, r6
; PPC64-NEXT:    or r8, r8, r9
; PPC64-NEXT:    stwcx. r8, 0, r5
; PPC64-NEXT:    bne cr0, .LBB13_1
; PPC64-NEXT:  # %bb.2:
; PPC64-NEXT:    srw r3, r7, r3
; PPC64-NEXT:    lwsync
; PPC64-NEXT:    blr
  %val = atomicrmw xor i16* %mem, i16 %operand seq_cst
  ret i16 %val
}
define i32 @xchg_i32_acq_rel(i32* %mem, i32 %operand) {
; CHECK-LABEL: xchg_i32_acq_rel:
; CHECK:       # %bb.0:
; CHECK-NEXT:    lwsync
; CHECK-NEXT:  .LBB14_1:
; CHECK-NEXT:    lwarx r5, 0, r3
; CHECK-NEXT:    stwcx. r4, 0, r3
; CHECK-NEXT:    bne cr0, .LBB14_1
; CHECK-NEXT:  # %bb.2:
; CHECK-NEXT:    mr r3, r5
; CHECK-NEXT:    lwsync
; CHECK-NEXT:    blr
  %val = atomicrmw xchg i32* %mem, i32 %operand acq_rel
  ret i32 %val
}
define i64 @and_i64_release(i64* %mem, i64 %operand) {
; PPC32-LABEL: and_i64_release:
; PPC32:       # %bb.0:
; PPC32-NEXT:    mflr r0
; PPC32-NEXT:    stw r0, 4(r1)
; PPC32-NEXT:    stwu r1, -16(r1)
; PPC32-NEXT:    .cfi_def_cfa_offset 16
; PPC32-NEXT:    .cfi_offset lr, 4
; PPC32-NEXT:    li r7, 3
; PPC32-NEXT:    bl __atomic_fetch_and_8
; PPC32-NEXT:    lwz r0, 20(r1)
; PPC32-NEXT:    addi r1, r1, 16
; PPC32-NEXT:    mtlr r0
; PPC32-NEXT:    blr
;
; PPC64-LABEL: and_i64_release:
; PPC64:       # %bb.0:
; PPC64-NEXT:    lwsync
; PPC64-NEXT:  .LBB15_1:
; PPC64-NEXT:    ldarx r5, 0, r3
; PPC64-NEXT:    and r6, r4, r5
; PPC64-NEXT:    stdcx. r6, 0, r3
; PPC64-NEXT:    bne cr0, .LBB15_1
; PPC64-NEXT:  # %bb.2:
; PPC64-NEXT:    mr r3, r5
; PPC64-NEXT:    blr
  %val = atomicrmw and i64* %mem, i64 %operand release
  ret i64 %val
}