| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 | |
| ; RUN: llc < %s -mtriple=sparc -mcpu=v9 -mattr=+v8plus -verify-machineinstrs | FileCheck %s --check-prefix=V8PLUS | |
| ; RUN: llc < %s -mtriple=sparc -mcpu=v9 -verify-machineinstrs | FileCheck %s --check-prefix=V9 | |
| ;; 64-bit atomics in 32-bit V8+ code. Like GCC, atomic loads and stores use | |
| ;; ldd/std, and compare-and-swap uses casx on values packed into %g/%o | |
| ;; registers. Without V8+ these are all libcalls. | |
| define i64 @load_monotonic(ptr %p) nounwind { | |
| ; V8PLUS-LABEL: load_monotonic: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: retl | |
| ; V8PLUS-NEXT: ldd [%o0], %o0 | |
| ; | |
| ; V9-LABEL: load_monotonic: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -96, %sp | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: call __atomic_load_8 | |
| ; V9-NEXT: mov %g0, %o1 | |
| ; V9-NEXT: mov %o0, %i0 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore %g0, %o1, %o1 | |
| %v = load atomic i64, ptr %p monotonic, align 8 | |
| ret i64 %v | |
| } | |
| define i64 @load_seq_cst(ptr %p) nounwind { | |
| ; V8PLUS-LABEL: load_seq_cst: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: ldd [%o0], %o0 | |
| ; V8PLUS-NEXT: membar #LoadLoad | #LoadStore | |
| ; V8PLUS-NEXT: retl | |
| ; V8PLUS-NEXT: nop | |
| ; | |
| ; V9-LABEL: load_seq_cst: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -96, %sp | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: call __atomic_load_8 | |
| ; V9-NEXT: mov 5, %o1 | |
| ; V9-NEXT: mov %o0, %i0 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore %g0, %o1, %o1 | |
| %v = load atomic i64, ptr %p seq_cst, align 8 | |
| ret i64 %v | |
| } | |
| define void @store_monotonic(ptr %p, i64 %v) nounwind { | |
| ; V8PLUS-LABEL: store_monotonic: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: mov %o2, %o3 | |
| ; V8PLUS-NEXT: mov %o1, %o2 | |
| ; V8PLUS-NEXT: retl | |
| ; V8PLUS-NEXT: std %o2, [%o0] | |
| ; | |
| ; V9-LABEL: store_monotonic: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -96, %sp | |
| ; V9-NEXT: mov %i2, %o2 | |
| ; V9-NEXT: mov %i1, %o1 | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: call __atomic_store_8 | |
| ; V9-NEXT: mov %g0, %o3 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore | |
| store atomic i64 %v, ptr %p monotonic, align 8 | |
| ret void | |
| } | |
| define void @store_seq_cst(ptr %p, i64 %v) nounwind { | |
| ; V8PLUS-LABEL: store_seq_cst: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: mov %o2, %o3 | |
| ; V8PLUS-NEXT: membar #LoadStore | #StoreStore | |
| ; V8PLUS-NEXT: mov %o1, %o2 | |
| ; V8PLUS-NEXT: std %o2, [%o0] | |
| ; V8PLUS-NEXT: membar #LoadLoad | #StoreLoad | #LoadStore | #StoreStore | |
| ; V8PLUS-NEXT: retl | |
| ; V8PLUS-NEXT: nop | |
| ; | |
| ; V9-LABEL: store_seq_cst: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -96, %sp | |
| ; V9-NEXT: mov %i2, %o2 | |
| ; V9-NEXT: mov %i1, %o1 | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: call __atomic_store_8 | |
| ; V9-NEXT: mov 5, %o3 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore | |
| store atomic i64 %v, ptr %p seq_cst, align 8 | |
| ret void | |
| } | |
| define void @store_zero(ptr %p) nounwind { | |
| ; V8PLUS-LABEL: store_zero: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: mov %g0, %o2 | |
| ; V8PLUS-NEXT: mov %g0, %o3 | |
| ; V8PLUS-NEXT: retl | |
| ; V8PLUS-NEXT: std %o2, [%o0] | |
| ; | |
| ; V9-LABEL: store_zero: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -96, %sp | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: mov %g0, %o1 | |
| ; V9-NEXT: mov %g0, %o2 | |
| ; V9-NEXT: call __atomic_store_8 | |
| ; V9-NEXT: mov %g0, %o3 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore | |
| store atomic i64 0, ptr %p monotonic, align 8 | |
| ret void | |
| } | |
| define i64 @cmpxchg_monotonic(ptr %p, i64 %cmp, i64 %new) nounwind { | |
| ; V8PLUS-LABEL: cmpxchg_monotonic: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: srl %o4, 0, %g3 | |
| ; V8PLUS-NEXT: sllx %o3, 32, %g4 | |
| ; V8PLUS-NEXT: or %g3, %g4, %g3 | |
| ; V8PLUS-NEXT: srl %o2, 0, %g4 | |
| ; V8PLUS-NEXT: sllx %o1, 32, %g2 | |
| ; V8PLUS-NEXT: or %g4, %g2, %g4 | |
| ; V8PLUS-NEXT: casx [%o0], %g4, %g3 | |
| ; V8PLUS-NEXT: srlx %g3, 32, %g2 | |
| ; V8PLUS-NEXT: mov %g2, %o0 | |
| ; V8PLUS-NEXT: retl | |
| ; V8PLUS-NEXT: mov %g3, %o1 | |
| ; | |
| ; V9-LABEL: cmpxchg_monotonic: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -104, %sp | |
| ; V9-NEXT: mov %i2, %g3 | |
| ; V9-NEXT: mov %i4, %o3 | |
| ; V9-NEXT: mov %i3, %o2 | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: mov %i1, %g2 | |
| ; V9-NEXT: std %g2, [%fp+-8] | |
| ; V9-NEXT: add %fp, -8, %o1 | |
| ; V9-NEXT: mov %g0, %o4 | |
| ; V9-NEXT: call __atomic_compare_exchange_8 | |
| ; V9-NEXT: mov %g0, %o5 | |
| ; V9-NEXT: ldd [%fp+-8], %i0 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore | |
| %pair = cmpxchg ptr %p, i64 %cmp, i64 %new monotonic monotonic | |
| %v = extractvalue { i64, i1 } %pair, 0 | |
| ret i64 %v | |
| } | |
| define i1 @cmpxchg_seq_cst_success(ptr %p, i64 %cmp, i64 %new) nounwind { | |
| ; V8PLUS-LABEL: cmpxchg_seq_cst_success: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: membar #LoadStore | #StoreStore | |
| ; V8PLUS-NEXT: srl %o4, 0, %g3 | |
| ; V8PLUS-NEXT: sllx %o3, 32, %g4 | |
| ; V8PLUS-NEXT: or %g3, %g4, %g3 | |
| ; V8PLUS-NEXT: srl %o2, 0, %g4 | |
| ; V8PLUS-NEXT: sllx %o1, 32, %g2 | |
| ; V8PLUS-NEXT: or %g4, %g2, %g4 | |
| ; V8PLUS-NEXT: casx [%o0], %g4, %g3 | |
| ; V8PLUS-NEXT: srlx %g3, 32, %g2 | |
| ; V8PLUS-NEXT: mov %g0, %o0 | |
| ; V8PLUS-NEXT: xor %g2, %o1, %o1 | |
| ; V8PLUS-NEXT: xor %g3, %o2, %o2 | |
| ; V8PLUS-NEXT: orcc %o2, %o1, %g0 | |
| ; V8PLUS-NEXT: move %icc, 1, %o0 | |
| ; V8PLUS-NEXT: membar #LoadLoad | #LoadStore | |
| ; V8PLUS-NEXT: retl | |
| ; V8PLUS-NEXT: nop | |
| ; | |
| ; V9-LABEL: cmpxchg_seq_cst_success: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -104, %sp | |
| ; V9-NEXT: mov %i2, %g3 | |
| ; V9-NEXT: mov %i4, %o3 | |
| ; V9-NEXT: mov %i3, %o2 | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: mov %i1, %g2 | |
| ; V9-NEXT: std %g2, [%fp+-8] | |
| ; V9-NEXT: add %fp, -8, %o1 | |
| ; V9-NEXT: mov 5, %o4 | |
| ; V9-NEXT: call __atomic_compare_exchange_8 | |
| ; V9-NEXT: mov %o4, %o5 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore %g0, %o0, %o0 | |
| %pair = cmpxchg ptr %p, i64 %cmp, i64 %new seq_cst seq_cst | |
| %ok = extractvalue { i64, i1 } %pair, 1 | |
| ret i1 %ok | |
| } | |
| define i64 @cmpxchg_const(ptr %p, i64 %cmp) nounwind { | |
| ; V8PLUS-LABEL: cmpxchg_const: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: mov 123, %o3 | |
| ; V8PLUS-NEXT: srl %o3, 0, %g3 | |
| ; V8PLUS-NEXT: sllx %g0, 32, %g4 | |
| ; V8PLUS-NEXT: or %g3, %g4, %g3 | |
| ; V8PLUS-NEXT: srl %o2, 0, %g4 | |
| ; V8PLUS-NEXT: sllx %o1, 32, %g2 | |
| ; V8PLUS-NEXT: or %g4, %g2, %g4 | |
| ; V8PLUS-NEXT: casx [%o0], %g4, %g3 | |
| ; V8PLUS-NEXT: srlx %g3, 32, %g2 | |
| ; V8PLUS-NEXT: mov %g2, %o0 | |
| ; V8PLUS-NEXT: retl | |
| ; V8PLUS-NEXT: mov %g3, %o1 | |
| ; | |
| ; V9-LABEL: cmpxchg_const: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -104, %sp | |
| ; V9-NEXT: mov %i2, %i3 | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: mov %i1, %i2 | |
| ; V9-NEXT: std %i2, [%fp+-8] | |
| ; V9-NEXT: add %fp, -8, %o1 | |
| ; V9-NEXT: mov 123, %o3 | |
| ; V9-NEXT: mov %g0, %o2 | |
| ; V9-NEXT: mov %g0, %o4 | |
| ; V9-NEXT: call __atomic_compare_exchange_8 | |
| ; V9-NEXT: mov %g0, %o5 | |
| ; V9-NEXT: ldd [%fp+-8], %i0 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore | |
| %pair = cmpxchg ptr %p, i64 %cmp, i64 123 monotonic monotonic | |
| %v = extractvalue { i64, i1 } %pair, 0 | |
| ret i64 %v | |
| } | |
| ;; The compare and new values are the same, so the inputs can share registers. | |
| define i64 @cmpxchg_same(ptr %p, i64 %v) nounwind { | |
| ; V8PLUS-LABEL: cmpxchg_same: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: srl %o2, 0, %g3 | |
| ; V8PLUS-NEXT: sllx %o1, 32, %g4 | |
| ; V8PLUS-NEXT: or %g3, %g4, %g3 | |
| ; V8PLUS-NEXT: srl %o2, 0, %g4 | |
| ; V8PLUS-NEXT: sllx %o1, 32, %g2 | |
| ; V8PLUS-NEXT: or %g4, %g2, %g4 | |
| ; V8PLUS-NEXT: casx [%o0], %g4, %g3 | |
| ; V8PLUS-NEXT: srlx %g3, 32, %g2 | |
| ; V8PLUS-NEXT: mov %g2, %o0 | |
| ; V8PLUS-NEXT: retl | |
| ; V8PLUS-NEXT: mov %g3, %o1 | |
| ; | |
| ; V9-LABEL: cmpxchg_same: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -104, %sp | |
| ; V9-NEXT: mov %i2, %o3 | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: mov %i1, %o2 | |
| ; V9-NEXT: std %o2, [%fp+-8] | |
| ; V9-NEXT: add %fp, -8, %o1 | |
| ; V9-NEXT: mov %g0, %o4 | |
| ; V9-NEXT: call __atomic_compare_exchange_8 | |
| ; V9-NEXT: mov %g0, %o5 | |
| ; V9-NEXT: ldd [%fp+-8], %i0 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore | |
| %pair = cmpxchg ptr %p, i64 %v, i64 %v monotonic monotonic | |
| %r = extractvalue { i64, i1 } %pair, 0 | |
| ret i64 %r | |
| } | |
| define i64 @atomicrmw_xchg(ptr %p, i64 %v) nounwind { | |
| ; V8PLUS-LABEL: atomicrmw_xchg: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: ldd [%o0], %o4 | |
| ; V8PLUS-NEXT: .LBB9_1: ! %atomicrmw.start | |
| ; V8PLUS-NEXT: ! =>This Inner Loop Header: Depth=1 | |
| ; V8PLUS-NEXT: srl %o2, 0, %g3 | |
| ; V8PLUS-NEXT: sllx %o1, 32, %g4 | |
| ; V8PLUS-NEXT: or %g3, %g4, %g3 | |
| ; V8PLUS-NEXT: srl %o5, 0, %g4 | |
| ; V8PLUS-NEXT: sllx %o4, 32, %g2 | |
| ; V8PLUS-NEXT: or %g4, %g2, %g4 | |
| ; V8PLUS-NEXT: casx [%o0], %g4, %g3 | |
| ; V8PLUS-NEXT: srlx %g3, 32, %g2 | |
| ; V8PLUS-NEXT: xor %g2, %o4, %o3 | |
| ; V8PLUS-NEXT: xor %g3, %o5, %o4 | |
| ; V8PLUS-NEXT: orcc %o4, %o3, %g0 | |
| ; V8PLUS-NEXT: mov %g3, %o5 | |
| ; V8PLUS-NEXT: bne %icc, .LBB9_1 | |
| ; V8PLUS-NEXT: mov %g2, %o4 | |
| ; V8PLUS-NEXT: ! %bb.2: ! %atomicrmw.end | |
| ; V8PLUS-NEXT: mov %o4, %o0 | |
| ; V8PLUS-NEXT: retl | |
| ; V8PLUS-NEXT: mov %o5, %o1 | |
| ; | |
| ; V9-LABEL: atomicrmw_xchg: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -96, %sp | |
| ; V9-NEXT: mov %i2, %o2 | |
| ; V9-NEXT: mov %i1, %o1 | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: call __atomic_exchange_8 | |
| ; V9-NEXT: mov %g0, %o3 | |
| ; V9-NEXT: mov %o0, %i0 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore %g0, %o1, %o1 | |
| %r = atomicrmw xchg ptr %p, i64 %v monotonic | |
| ret i64 %r | |
| } | |
| define i64 @atomicrmw_add(ptr %p, i64 %v) nounwind { | |
| ; V8PLUS-LABEL: atomicrmw_add: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: save %sp, -96, %sp | |
| ; V8PLUS-NEXT: membar #LoadStore | #StoreStore | |
| ; V8PLUS-NEXT: ldd [%i0], %i4 | |
| ; V8PLUS-NEXT: .LBB10_1: ! %atomicrmw.start | |
| ; V8PLUS-NEXT: ! =>This Inner Loop Header: Depth=1 | |
| ; V8PLUS-NEXT: addcc %i5, %i2, %i3 | |
| ; V8PLUS-NEXT: addxcc %i4, %i1, %g2 | |
| ; V8PLUS-NEXT: srl %i3, 0, %g4 | |
| ; V8PLUS-NEXT: sllx %g2, 32, %o0 | |
| ; V8PLUS-NEXT: or %g4, %o0, %g4 | |
| ; V8PLUS-NEXT: srl %i5, 0, %o0 | |
| ; V8PLUS-NEXT: sllx %i4, 32, %g3 | |
| ; V8PLUS-NEXT: or %o0, %g3, %o0 | |
| ; V8PLUS-NEXT: casx [%i0], %o0, %g4 | |
| ; V8PLUS-NEXT: srlx %g4, 32, %g3 | |
| ; V8PLUS-NEXT: xor %g3, %i4, %i3 | |
| ; V8PLUS-NEXT: xor %g4, %i5, %i4 | |
| ; V8PLUS-NEXT: orcc %i4, %i3, %g0 | |
| ; V8PLUS-NEXT: mov %g4, %i5 | |
| ; V8PLUS-NEXT: bne %icc, .LBB10_1 | |
| ; V8PLUS-NEXT: mov %g3, %i4 | |
| ; V8PLUS-NEXT: ! %bb.2: ! %atomicrmw.end | |
| ; V8PLUS-NEXT: membar #LoadLoad | #LoadStore | |
| ; V8PLUS-NEXT: mov %i4, %i0 | |
| ; V8PLUS-NEXT: ret | |
| ; V8PLUS-NEXT: restore %g0, %i5, %o1 | |
| ; | |
| ; V9-LABEL: atomicrmw_add: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -96, %sp | |
| ; V9-NEXT: mov %i2, %o2 | |
| ; V9-NEXT: mov %i1, %o1 | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: call __atomic_fetch_add_8 | |
| ; V9-NEXT: mov 5, %o3 | |
| ; V9-NEXT: mov %o0, %i0 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore %g0, %o1, %o1 | |
| %r = atomicrmw add ptr %p, i64 %v seq_cst | |
| ret i64 %r | |
| } | |
| define i64 @atomicrmw_max(ptr %p, i64 %v) nounwind { | |
| ; V8PLUS-LABEL: atomicrmw_max: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: save %sp, -96, %sp | |
| ; V8PLUS-NEXT: membar #LoadStore | #StoreStore | |
| ; V8PLUS-NEXT: ldd [%i0], %i4 | |
| ; V8PLUS-NEXT: .LBB11_1: ! %atomicrmw.start | |
| ; V8PLUS-NEXT: ! =>This Inner Loop Header: Depth=1 | |
| ; V8PLUS-NEXT: mov %g0, %i3 | |
| ; V8PLUS-NEXT: mov %g0, %g2 | |
| ; V8PLUS-NEXT: cmp %i4, %i1 | |
| ; V8PLUS-NEXT: movg %icc, 1, %i3 | |
| ; V8PLUS-NEXT: cmp %i5, %i2 | |
| ; V8PLUS-NEXT: movgu %icc, 1, %g2 | |
| ; V8PLUS-NEXT: cmp %i4, %i1 | |
| ; V8PLUS-NEXT: move %icc, %g2, %i3 | |
| ; V8PLUS-NEXT: cmp %i3, 0 | |
| ; V8PLUS-NEXT: mov %i2, %i3 | |
| ; V8PLUS-NEXT: movne %icc, %i5, %i3 | |
| ; V8PLUS-NEXT: mov %i1, %g2 | |
| ; V8PLUS-NEXT: movne %icc, %i4, %g2 | |
| ; V8PLUS-NEXT: srl %i3, 0, %g4 | |
| ; V8PLUS-NEXT: sllx %g2, 32, %o0 | |
| ; V8PLUS-NEXT: or %g4, %o0, %g4 | |
| ; V8PLUS-NEXT: srl %i5, 0, %o0 | |
| ; V8PLUS-NEXT: sllx %i4, 32, %g3 | |
| ; V8PLUS-NEXT: or %o0, %g3, %o0 | |
| ; V8PLUS-NEXT: casx [%i0], %o0, %g4 | |
| ; V8PLUS-NEXT: srlx %g4, 32, %g3 | |
| ; V8PLUS-NEXT: xor %g3, %i4, %i3 | |
| ; V8PLUS-NEXT: xor %g4, %i5, %i4 | |
| ; V8PLUS-NEXT: orcc %i4, %i3, %g0 | |
| ; V8PLUS-NEXT: mov %g4, %i5 | |
| ; V8PLUS-NEXT: bne %icc, .LBB11_1 | |
| ; V8PLUS-NEXT: mov %g3, %i4 | |
| ; V8PLUS-NEXT: ! %bb.2: ! %atomicrmw.end | |
| ; V8PLUS-NEXT: membar #LoadLoad | #LoadStore | |
| ; V8PLUS-NEXT: mov %i4, %i0 | |
| ; V8PLUS-NEXT: ret | |
| ; V8PLUS-NEXT: restore %g0, %i5, %o1 | |
| ; | |
| ; V9-LABEL: atomicrmw_max: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -104, %sp | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: call __atomic_load_8 | |
| ; V9-NEXT: mov %g0, %o1 | |
| ; V9-NEXT: mov %o0, %g2 | |
| ; V9-NEXT: add %fp, -8, %i3 | |
| ; V9-NEXT: mov 5, %i4 | |
| ; V9-NEXT: mov %o1, %g3 | |
| ; V9-NEXT: .LBB11_1: ! %atomicrmw.start | |
| ; V9-NEXT: ! =>This Inner Loop Header: Depth=1 | |
| ; V9-NEXT: mov %g0, %i5 | |
| ; V9-NEXT: mov %g0, %g4 | |
| ; V9-NEXT: cmp %g2, %i1 | |
| ; V9-NEXT: movg %icc, 1, %i5 | |
| ; V9-NEXT: cmp %g3, %i2 | |
| ; V9-NEXT: movgu %icc, 1, %g4 | |
| ; V9-NEXT: cmp %g2, %i1 | |
| ; V9-NEXT: move %icc, %g4, %i5 | |
| ; V9-NEXT: cmp %i5, 0 | |
| ; V9-NEXT: mov %i1, %o2 | |
| ; V9-NEXT: movne %icc, %g2, %o2 | |
| ; V9-NEXT: mov %i2, %o3 | |
| ; V9-NEXT: movne %icc, %g3, %o3 | |
| ; V9-NEXT: std %g2, [%fp+-8] | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: mov %i3, %o1 | |
| ; V9-NEXT: mov %i4, %o4 | |
| ; V9-NEXT: call __atomic_compare_exchange_8 | |
| ; V9-NEXT: mov %i4, %o5 | |
| ; V9-NEXT: cmp %o0, 0 | |
| ; V9-NEXT: be %icc, .LBB11_1 | |
| ; V9-NEXT: ldd [%fp+-8], %g2 | |
| ; V9-NEXT: ! %bb.2: ! %atomicrmw.end | |
| ; V9-NEXT: mov %g2, %i0 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore %g0, %g3, %o1 | |
| %r = atomicrmw max ptr %p, i64 %v seq_cst | |
| ret i64 %r | |
| } | |
| ;; The 64-bit temporaries must stay in %g/%o registers even when values are | |
| ;; live across the casx in callee-saved %l/%i registers. | |
| declare void @use(i64) | |
| define i64 @cmpxchg_live_across(ptr %p, i64 %cmp, i64 %new, i64 %x) nounwind { | |
| ; V8PLUS-LABEL: cmpxchg_live_across: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: save %sp, -104, %sp | |
| ; V8PLUS-NEXT: ld [%fp+92], %o1 | |
| ; V8PLUS-NEXT: srl %i4, 0, %g3 | |
| ; V8PLUS-NEXT: sllx %i3, 32, %g2 | |
| ; V8PLUS-NEXT: or %g3, %g2, %g3 | |
| ; V8PLUS-NEXT: srl %i2, 0, %g2 | |
| ; V8PLUS-NEXT: sllx %i1, 32, %g4 | |
| ; V8PLUS-NEXT: or %g2, %g4, %g2 | |
| ; V8PLUS-NEXT: casx [%i0], %g2, %g3 | |
| ; V8PLUS-NEXT: srlx %g3, 32, %g4 | |
| ; V8PLUS-NEXT: st %g4, [%fp+-8] ! 4-byte Folded Spill | |
| ; V8PLUS-NEXT: st %g3, [%fp+-4] ! 4-byte Folded Spill | |
| ; V8PLUS-NEXT: call use | |
| ; V8PLUS-NEXT: mov %i5, %o0 | |
| ; V8PLUS-NEXT: mov %i1, %o0 | |
| ; V8PLUS-NEXT: call use | |
| ; V8PLUS-NEXT: mov %i2, %o1 | |
| ; V8PLUS-NEXT: mov %i3, %o0 | |
| ; V8PLUS-NEXT: call use | |
| ; V8PLUS-NEXT: mov %i4, %o1 | |
| ; V8PLUS-NEXT: ld [%fp+-8], %i0 ! 4-byte Folded Reload | |
| ; V8PLUS-NEXT: ld [%fp+-4], %i1 ! 4-byte Folded Reload | |
| ; V8PLUS-NEXT: ret | |
| ; V8PLUS-NEXT: restore | |
| ; | |
| ; V9-LABEL: cmpxchg_live_across: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -104, %sp | |
| ; V9-NEXT: ld [%fp+92], %l2 | |
| ; V9-NEXT: mov %i2, %l1 | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: mov %i1, %l0 | |
| ; V9-NEXT: std %l0, [%fp+-8] | |
| ; V9-NEXT: add %fp, -8, %o1 | |
| ; V9-NEXT: mov %i3, %o2 | |
| ; V9-NEXT: mov %i4, %o3 | |
| ; V9-NEXT: mov %g0, %o4 | |
| ; V9-NEXT: call __atomic_compare_exchange_8 | |
| ; V9-NEXT: mov %g0, %o5 | |
| ; V9-NEXT: ldd [%fp+-8], %i0 | |
| ; V9-NEXT: mov %i5, %o0 | |
| ; V9-NEXT: call use | |
| ; V9-NEXT: mov %l2, %o1 | |
| ; V9-NEXT: mov %l0, %o0 | |
| ; V9-NEXT: call use | |
| ; V9-NEXT: mov %l1, %o1 | |
| ; V9-NEXT: mov %i3, %o0 | |
| ; V9-NEXT: call use | |
| ; V9-NEXT: mov %i4, %o1 | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore | |
| %pair = cmpxchg ptr %p, i64 %cmp, i64 %new monotonic monotonic | |
| %v = extractvalue { i64, i1 } %pair, 0 | |
| call void @use(i64 %x) | |
| call void @use(i64 %cmp) | |
| call void @use(i64 %new) | |
| ret i64 %v | |
| } | |
| ;; The 64-bit result is stored with std after a call, so it is spilled as a | |
| ;; register pair whose halves are restricted to %g/%o registers. | |
| define void @cmpxchg_spill_pair(ptr %p, ptr %q, i64 %cmp, i64 %new) nounwind { | |
| ; V8PLUS-LABEL: cmpxchg_spill_pair: | |
| ; V8PLUS: ! %bb.0: | |
| ; V8PLUS-NEXT: save %sp, -104, %sp | |
| ; V8PLUS-NEXT: srl %i5, 0, %o1 | |
| ; V8PLUS-NEXT: sllx %i4, 32, %g2 | |
| ; V8PLUS-NEXT: or %o1, %g2, %o1 | |
| ; V8PLUS-NEXT: srl %i3, 0, %g2 | |
| ; V8PLUS-NEXT: sllx %i2, 32, %o0 | |
| ; V8PLUS-NEXT: or %g2, %o0, %g2 | |
| ; V8PLUS-NEXT: casx [%i0], %g2, %o1 | |
| ; V8PLUS-NEXT: srlx %o1, 32, %o0 | |
| ; V8PLUS-NEXT: std %o0, [%fp+-8] ! 8-byte Folded Spill | |
| ; V8PLUS-NEXT: mov %g0, %o0 | |
| ; V8PLUS-NEXT: call use | |
| ; V8PLUS-NEXT: mov %g0, %o1 | |
| ; V8PLUS-NEXT: ldd [%fp+-8], %g2 ! 8-byte Folded Reload | |
| ; V8PLUS-NEXT: std %g2, [%i1] | |
| ; V8PLUS-NEXT: ret | |
| ; V8PLUS-NEXT: restore | |
| ; | |
| ; V9-LABEL: cmpxchg_spill_pair: | |
| ; V9: ! %bb.0: | |
| ; V9-NEXT: save %sp, -104, %sp | |
| ; V9-NEXT: ! kill: def $i3 killed $i3 killed $i2_i3 def $i2_i3 | |
| ; V9-NEXT: mov %i5, %o3 | |
| ; V9-NEXT: mov %i4, %o2 | |
| ; V9-NEXT: mov %i0, %o0 | |
| ; V9-NEXT: ! kill: def $i2 killed $i2 killed $i2_i3 def $i2_i3 | |
| ; V9-NEXT: std %i2, [%fp+-8] | |
| ; V9-NEXT: add %fp, -8, %o1 | |
| ; V9-NEXT: mov %g0, %o4 | |
| ; V9-NEXT: call __atomic_compare_exchange_8 | |
| ; V9-NEXT: mov %g0, %o5 | |
| ; V9-NEXT: ldd [%fp+-8], %i2 | |
| ; V9-NEXT: mov %g0, %o0 | |
| ; V9-NEXT: call use | |
| ; V9-NEXT: mov %g0, %o1 | |
| ; V9-NEXT: std %i2, [%i1] | |
| ; V9-NEXT: ret | |
| ; V9-NEXT: restore | |
| %pair = cmpxchg ptr %p, i64 %cmp, i64 %new monotonic monotonic | |
| %v = extractvalue { i64, i1 } %pair, 0 | |
| call void @use(i64 0) | |
| store i64 %v, ptr %q, align 8 | |
| ret void | |
| } |