1; Test 32-bit addition in which the second operand is constant. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4 5declare i32 @foo() 6 7; Check addition of 1. 8define zeroext i1 @f1(i32 %dummy, i32 %a, i32 *%res) { 9; CHECK-LABEL: f1: 10; CHECK: alfi %r3, 1 11; CHECK-DAG: st %r3, 0(%r4) 12; CHECK-DAG: ipm [[REG:%r[0-5]]] 13; CHECK-DAG: risbg %r2, [[REG]], 63, 191, 35 14; CHECK: br %r14 15 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 1) 16 %val = extractvalue {i32, i1} %t, 0 17 %obit = extractvalue {i32, i1} %t, 1 18 store i32 %val, i32 *%res 19 ret i1 %obit 20} 21 22; Check the high end of the ALFI range. 23define zeroext i1 @f2(i32 %dummy, i32 %a, i32 *%res) { 24; CHECK-LABEL: f2: 25; CHECK: alfi %r3, 4294967295 26; CHECK-DAG: st %r3, 0(%r4) 27; CHECK-DAG: ipm [[REG:%r[0-5]]] 28; CHECK-DAG: risbg %r2, [[REG]], 63, 191, 35 29; CHECK: br %r14 30 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 4294967295) 31 %val = extractvalue {i32, i1} %t, 0 32 %obit = extractvalue {i32, i1} %t, 1 33 store i32 %val, i32 *%res 34 ret i1 %obit 35} 36 37; Check that negative values are treated as unsigned 38define zeroext i1 @f3(i32 %dummy, i32 %a, i32 *%res) { 39; CHECK-LABEL: f3: 40; CHECK: alfi %r3, 4294967295 41; CHECK-DAG: st %r3, 0(%r4) 42; CHECK-DAG: ipm [[REG:%r[0-5]]] 43; CHECK-DAG: risbg %r2, [[REG]], 63, 191, 35 44; CHECK: br %r14 45 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 -1) 46 %val = extractvalue {i32, i1} %t, 0 47 %obit = extractvalue {i32, i1} %t, 1 48 store i32 %val, i32 *%res 49 ret i1 %obit 50} 51 52; Check using the overflow result for a branch. 53define void @f4(i32 %dummy, i32 %a, i32 *%res) { 54; CHECK-LABEL: f4: 55; CHECK: alfi %r3, 1 56; CHECK: st %r3, 0(%r4) 57; CHECK: jgnle foo@PLT 58; CHECK: br %r14 59 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 1) 60 %val = extractvalue {i32, i1} %t, 0 61 %obit = extractvalue {i32, i1} %t, 1 62 store i32 %val, i32 *%res 63 br i1 %obit, label %call, label %exit 64 65call: 66 tail call i32 @foo() 67 br label %exit 68 69exit: 70 ret void 71} 72 73; ... and the same with the inverted direction. 74define void @f5(i32 %dummy, i32 %a, i32 *%res) { 75; CHECK-LABEL: f5: 76; CHECK: alfi %r3, 1 77; CHECK: st %r3, 0(%r4) 78; CHECK: jgle foo@PLT 79; CHECK: br %r14 80 %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 1) 81 %val = extractvalue {i32, i1} %t, 0 82 %obit = extractvalue {i32, i1} %t, 1 83 store i32 %val, i32 *%res 84 br i1 %obit, label %exit, label %call 85 86call: 87 tail call i32 @foo() 88 br label %exit 89 90exit: 91 ret void 92} 93 94declare {i32, i1} @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone 95 96