1 ; Test 128-bit addition when the distinct-operands facility is available.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
5 ; Test the case where both operands are in registers.
6 define i64 @f1(i64 %a, i64 %b, i64 %c, i64 %d, i64 *%ptr) {
8 ; CHECK: algrk %r2, %r4, %r5
11 %x1 = insertelement <2 x i64> undef, i64 %b, i32 0
12 %x2 = insertelement <2 x i64> %x1, i64 %c, i32 1
13 %x = bitcast <2 x i64> %x2 to i128
14 %y2 = insertelement <2 x i64> %x1, i64 %d, i32 1
15 %y = bitcast <2 x i64> %y2 to i128
16 %add = add i128 %x, %y
17 %addv = bitcast i128 %add to <2 x i64>
18 %high = extractelement <2 x i64> %addv, i32 0
19 store i64 %high, i64 *%ptr
20 %low = extractelement <2 x i64> %addv, i32 1
25 define void @f2(i64 %a, i64 %b, i128 *%ptr) {
27 ; CHECK: alghsik {{%r[0-5]}}, %r3, 1
30 %x1 = insertelement <2 x i64> undef, i64 %a, i32 0
31 %x2 = insertelement <2 x i64> %x1, i64 %b, i32 1
32 %x = bitcast <2 x i64> %x2 to i128
34 store i128 %add, i128 *%ptr
38 ; Test the upper end of the ALGHSIK range.
39 define void @f3(i64 %a, i64 %b, i128 *%ptr) {
41 ; CHECK: alghsik {{%r[0-5]}}, %r3, 32767
44 %x1 = insertelement <2 x i64> undef, i64 %a, i32 0
45 %x2 = insertelement <2 x i64> %x1, i64 %b, i32 1
46 %x = bitcast <2 x i64> %x2 to i128
47 %add = add i128 %x, 32767
48 store i128 %add, i128 *%ptr
52 ; Test the next value up, which should use ALGFI instead.
53 define void @f4(i64 %a, i64 %b, i128 *%ptr) {
55 ; CHECK: algfi %r3, 32768
58 %x1 = insertelement <2 x i64> undef, i64 %a, i32 0
59 %x2 = insertelement <2 x i64> %x1, i64 %b, i32 1
60 %x = bitcast <2 x i64> %x2 to i128
61 %add = add i128 %x, 32768
62 store i128 %add, i128 *%ptr
66 ; Test the lower end of the ALGHSIK range.
67 define void @f5(i64 %a, i64 %b, i128 *%ptr) {
69 ; CHECK: alghsik {{%r[0-5]}}, %r3, -32768
72 %x1 = insertelement <2 x i64> undef, i64 %a, i32 0
73 %x2 = insertelement <2 x i64> %x1, i64 %b, i32 1
74 %x = bitcast <2 x i64> %x2 to i128
75 %add = add i128 %x, -32768
76 store i128 %add, i128 *%ptr
80 ; Test the next value down, which cannot use either ALGHSIK or ALGFI.
81 define void @f6(i64 %a, i64 %b, i128 *%ptr) {
87 %x1 = insertelement <2 x i64> undef, i64 %a, i32 0
88 %x2 = insertelement <2 x i64> %x1, i64 %b, i32 1
89 %x = bitcast <2 x i64> %x2 to i128
90 %add = add i128 %x, -32769
91 store i128 %add, i128 *%ptr