1 ; Test 32-bit addition in which the second operand is constant.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
8 define zeroext i1 @f1(i32 %dummy, i32 %a, i32 *%res) {
11 ; CHECK-DAG: st %r3, 0(%r4)
12 ; CHECK-DAG: ipm [[REG:%r[0-5]]]
13 ; CHECK-DAG: risbg %r2, [[REG]], 63, 191, 35
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
22 ; Check the high end of the ALFI range.
23 define zeroext i1 @f2(i32 %dummy, i32 %a, i32 *%res) {
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
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
37 ; Check that negative values are treated as unsigned
38 define zeroext i1 @f3(i32 %dummy, i32 %a, i32 *%res) {
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
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
52 ; Check using the overflow result for a branch.
53 define void @f4(i32 %dummy, i32 %a, i32 *%res) {
56 ; CHECK: st %r3, 0(%r4)
57 ; CHECK: jgnle foo@PLT
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
73 ; ... and the same with the inverted direction.
74 define void @f5(i32 %dummy, i32 %a, i32 *%res) {
77 ; CHECK: st %r3, 0(%r4)
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
94 declare {i32, i1} @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone