1; Test 128-bit addition when the distinct-operands facility is available. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s 4 5; Test the case where both operands are in registers. 6define i64 @f1(i64 %a, i64 %b, i64 %c, i64 %d, i64 *%ptr) { 7; CHECK-LABEL: f1: 8; CHECK: algrk %r2, %r4, %r5 9; CHECK: alcgr 10; CHECK: br %r14 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 21 ret i64 %low 22} 23 24; Test addition of 1. 25define void @f2(i64 %a, i64 %b, i128 *%ptr) { 26; CHECK-LABEL: f2: 27; CHECK: alghsik {{%r[0-5]}}, %r3, 1 28; CHECK: alcgr 29; CHECK: br %r14 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 33 %add = add i128 %x, 1 34 store i128 %add, i128 *%ptr 35 ret void 36} 37 38; Test the upper end of the ALGHSIK range. 39define void @f3(i64 %a, i64 %b, i128 *%ptr) { 40; CHECK-LABEL: f3: 41; CHECK: alghsik {{%r[0-5]}}, %r3, 32767 42; CHECK: alcgr 43; CHECK: br %r14 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 49 ret void 50} 51 52; Test the next value up, which should use ALGFI instead. 53define void @f4(i64 %a, i64 %b, i128 *%ptr) { 54; CHECK-LABEL: f4: 55; CHECK: algfi %r3, 32768 56; CHECK: alcgr 57; CHECK: br %r14 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 63 ret void 64} 65 66; Test the lower end of the ALGHSIK range. 67define void @f5(i64 %a, i64 %b, i128 *%ptr) { 68; CHECK-LABEL: f5: 69; CHECK: alghsik {{%r[0-5]}}, %r3, -32768 70; CHECK: alcgr 71; CHECK: br %r14 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 77 ret void 78} 79 80; Test the next value down, which cannot use either ALGHSIK or ALGFI. 81define void @f6(i64 %a, i64 %b, i128 *%ptr) { 82; CHECK-LABEL: f6: 83; CHECK-NOT: alghsik 84; CHECK-NOT: algfi 85; CHECK: alcgr 86; CHECK: br %r14 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 92 ret void 93} 94