1 ; Test the three-operand form of 32-bit subtraction.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
5 declare i32 @foo(i32, i32, i32)
8 define i32 @f1(i32 %dummy, i32 %a, i32 %b, i32 *%flag) {
10 ; CHECK: slrk %r2, %r3, %r4
11 ; CHECK: ipm [[REG:%r[0-5]]]
12 ; CHECK: afi [[REG]], -536870912
13 ; CHECK: srl [[REG]], 31
14 ; CHECK: st [[REG]], 0(%r5)
16 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
17 %val = extractvalue {i32, i1} %t, 0
18 %obit = extractvalue {i32, i1} %t, 1
19 %ext = zext i1 %obit to i32
20 store i32 %ext, i32 *%flag
24 ; Check using the overflow result for a branch.
25 define i32 @f2(i32 %dummy, i32 %a, i32 %b) {
27 ; CHECK: slrk %r2, %r3, %r4
28 ; CHECK-NEXT: bnler %r14
31 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
32 %val = extractvalue {i32, i1} %t, 0
33 %obit = extractvalue {i32, i1} %t, 1
34 br i1 %obit, label %call, label %exit
37 %res = tail call i32 @foo(i32 0, i32 %a, i32 %b)
44 ; ... and the same with the inverted direction.
45 define i32 @f3(i32 %dummy, i32 %a, i32 %b) {
47 ; CHECK: slrk %r2, %r3, %r4
48 ; CHECK-NEXT: bler %r14
51 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
52 %val = extractvalue {i32, i1} %t, 0
53 %obit = extractvalue {i32, i1} %t, 1
54 br i1 %obit, label %exit, label %call
57 %res = tail call i32 @foo(i32 0, i32 %a, i32 %b)
64 ; Check that we can still use SLR in obvious cases.
65 define i32 @f4(i32 %a, i32 %b, i32 *%flag) {
68 ; CHECK: ipm [[REG:%r[0-5]]]
69 ; CHECK: afi [[REG]], -536870912
70 ; CHECK: srl [[REG]], 31
71 ; CHECK: st [[REG]], 0(%r4)
73 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
74 %val = extractvalue {i32, i1} %t, 0
75 %obit = extractvalue {i32, i1} %t, 1
76 %ext = zext i1 %obit to i32
77 store i32 %ext, i32 *%flag
81 declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone