1; Test 8-bit atomic exchange. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-SHIFT 5 6; Check exchange with a variable. 7; - CHECK is for the main loop. 8; - CHECK-SHIFT makes sure that the negated shift count used by the second 9; RLL is set up correctly. The negation is independent of the NILL and L 10; tested in CHECK. CHECK-SHIFT also checks that %r3 is not modified before 11; being used in the RISBG (in contrast to things like atomic addition, 12; which shift %r3 left so that %b is at the high end of the word). 13define i8 @f1(i8 *%src, i8 %b) { 14; CHECK-LABEL: f1: 15; CHECK: risbg [[RISBG:%r[1-9]+]], %r2, 0, 189, 0{{$}} 16; CHECK: sll %r2, 3 17; CHECK: l [[OLD:%r[0-9]+]], 0([[RISBG]]) 18; CHECK: [[LABEL:\.[^:]*]]: 19; CHECK: rll [[ROT:%r[0-9]+]], [[OLD]], 0(%r2) 20; CHECK: risbg [[ROT]], %r3, 32, 39, 24 21; CHECK: rll [[NEW:%r[0-9]+]], [[ROT]], 0({{%r[1-9]+}}) 22; CHECK: cs [[OLD]], [[NEW]], 0([[RISBG]]) 23; CHECK: jl [[LABEL]] 24; CHECK: rll %r2, [[OLD]], 8(%r2) 25; CHECK: br %r14 26; 27; CHECK-SHIFT-LABEL: f1: 28; CHECK-SHIFT-NOT: %r3 29; CHECK-SHIFT: sll %r2, 3 30; CHECK-SHIFT-NOT: %r3 31; CHECK-SHIFT: lcr [[NEGSHIFT:%r[1-9]+]], %r2 32; CHECK-SHIFT-NOT: %r3 33; CHECK-SHIFT: rll 34; CHECK-SHIFT-NOT: %r3 35; CHECK-SHIFT: risbg {{%r[0-9]+}}, %r3, 32, 39, 24 36; CHECK-SHIFT: rll {{%r[0-9]+}}, {{%r[0-9]+}}, 0([[NEGSHIFT]]) 37; CHECK-SHIFT: rll 38; CHECK-SHIFT: br %r14 39 %res = atomicrmw xchg i8 *%src, i8 %b seq_cst 40 ret i8 %res 41} 42 43; Check exchange with a constant. We should force the constant into 44; a register and use the sequence above. 45define i8 @f2(i8 *%src) { 46; CHECK-LABEL: f2: 47; CHECK: lhi [[VALUE:%r[0-9]+]], 88 48; CHECK: risbg {{%r[0-9]+}}, [[VALUE]], 32, 39, 24 49; CHECK: br %r14 50; 51; CHECK-SHIFT-LABEL: f2: 52; CHECK-SHIFT: br %r14 53 %res = atomicrmw xchg i8 *%src, i8 88 seq_cst 54 ret i8 %res 55} 56