1; Test 64-bit atomic subtractions, z196 version. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s 4 5; Check addition of a variable. 6define i64 @f1(i64 %dummy, i64 *%src, i64 %b) { 7; CHECK-LABEL: f1: 8; CHECK: lcgr [[NEG:%r[0-5]]], %r4 9; CHECK: laag %r2, [[NEG]], 0(%r3) 10; CHECK: br %r14 11 %res = atomicrmw sub i64 *%src, i64 %b seq_cst 12 ret i64 %res 13} 14 15; Check addition of 1, which needs a temporary. 16define i64 @f2(i64 %dummy, i64 *%src) { 17; CHECK-LABEL: f2: 18; CHECK: lghi [[TMP:%r[0-5]]], -1 19; CHECK: laag %r2, [[TMP]], 0(%r3) 20; CHECK: br %r14 21 %res = atomicrmw sub i64 *%src, i64 1 seq_cst 22 ret i64 %res 23} 24 25; Check the high end of the LAAG range. 26define i64 @f3(i64 %dummy, i64 *%src, i64 %b) { 27; CHECK-LABEL: f3: 28; CHECK: lcgr [[NEG:%r[0-5]]], %r4 29; CHECK: laag %r2, [[NEG]], 524280(%r3) 30; CHECK: br %r14 31 %ptr = getelementptr i64, i64 *%src, i64 65535 32 %res = atomicrmw sub i64 *%ptr, i64 %b seq_cst 33 ret i64 %res 34} 35 36; Check the next doubleword up, which needs separate address logic. 37define i64 @f4(i64 %dummy, i64 *%src, i64 %b) { 38; CHECK-LABEL: f4: 39; CHECK-DAG: lcgr [[NEG:%r[0-5]]], %r4 40; CHECK-DAG: agfi %r3, 524288 41; CHECK: laag %r2, [[NEG]], 0(%r3) 42; CHECK: br %r14 43 %ptr = getelementptr i64, i64 *%src, i64 65536 44 %res = atomicrmw sub i64 *%ptr, i64 %b seq_cst 45 ret i64 %res 46} 47 48; Check the low end of the LAAG range. 49define i64 @f5(i64 %dummy, i64 *%src, i64 %b) { 50; CHECK-LABEL: f5: 51; CHECK: lcgr [[NEG:%r[0-5]]], %r4 52; CHECK: laag %r2, [[NEG]], -524288(%r3) 53; CHECK: br %r14 54 %ptr = getelementptr i64, i64 *%src, i64 -65536 55 %res = atomicrmw sub i64 *%ptr, i64 %b seq_cst 56 ret i64 %res 57} 58 59; Check the next doubleword down, which needs separate address logic. 60define i64 @f6(i64 %dummy, i64 *%src, i64 %b) { 61; CHECK-LABEL: f6: 62; CHECK-DAG: lcgr [[NEG:%r[0-5]]], %r4 63; CHECK-DAG: agfi %r3, -524296 64; CHECK: laag %r2, [[NEG]], 0(%r3) 65; CHECK: br %r14 66 %ptr = getelementptr i64, i64 *%src, i64 -65537 67 %res = atomicrmw sub i64 *%ptr, i64 %b seq_cst 68 ret i64 %res 69} 70