56 lines · plain
1; Test 16-bit atomic exchange.2;3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-SHIFT5 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 second9; RLL is set up correctly. The negation is independent of the NILL and L10; tested in CHECK. CHECK-SHIFT also checks that %r3 is not modified before11; 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 i16 @f1(ptr %src, i16 %b) {14; CHECK-LABEL: f1:15; CHECK: risbg [[RISBG:%r[1-9]+]], %r2, 0, 189, 0{{$}}16; CHECK-DAG: sll %r2, 317; CHECK-DAG: 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, 47, 1621; 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]], 16(%r2)25; CHECK: br %r1426;27; CHECK-SHIFT-LABEL: f1:28; CHECK-SHIFT-NOT: %r329; CHECK-SHIFT: sll %r2, 330; CHECK-SHIFT-NOT: %r331; CHECK-SHIFT: lcr [[NEGSHIFT:%r[1-9]+]], %r232; CHECK-SHIFT-NOT: %r333; CHECK-SHIFT: rll34; CHECK-SHIFT-NOT: %r335; CHECK-SHIFT: risbg {{%r[0-9]+}}, %r3, 32, 47, 1636; CHECK-SHIFT: rll {{%r[0-9]+}}, {{%r[0-9]+}}, 0([[NEGSHIFT]])37; CHECK-SHIFT: rll38; CHECK-SHIFT: br %r1439 %res = atomicrmw xchg ptr %src, i16 %b seq_cst40 ret i16 %res41}42 43; Check exchange with a constant. We should force the constant into44; a register and use the sequence above.45define i16 @f2(ptr %src) {46; CHECK-LABEL: f2:47; CHECK: lhi [[VALUE:%r[0-9]+]], -2553648; CHECK: risbg {{%r[0-9]+}}, [[VALUE]], 32, 47, 1649; CHECK: br %r1450;51; CHECK-SHIFT-LABEL: f2:52; CHECK-SHIFT: br %r1453 %res = atomicrmw xchg ptr %src, i16 40000 seq_cst54 ret i16 %res55}56