1 ; Test additions between an i64 and a sign-extended i16 on z14.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s
7 ; Check AGH with no displacement.
8 define i64 @f1(i64 %a, ptr %src) {
10 ; CHECK: agh %r2, 0(%r3)
12 %b = load i16, ptr %src
13 %bext = sext i16 %b to i64
14 %add = add i64 %a, %bext
18 ; Check the high end of the aligned AGH range.
19 define i64 @f2(i64 %a, ptr %src) {
21 ; CHECK: agh %r2, 524286(%r3)
23 %ptr = getelementptr i16, ptr %src, i64 262143
24 %b = load i16, ptr %ptr
25 %bext = sext i16 %b to i64
26 %add = add i64 %a, %bext
30 ; Check the next word up, which needs separate address logic.
31 ; Other sequences besides this one would be OK.
32 define i64 @f3(i64 %a, ptr %src) {
34 ; CHECK: agfi %r3, 524288
35 ; CHECK: agh %r2, 0(%r3)
37 %ptr = getelementptr i16, ptr %src, i64 262144
38 %b = load i16, ptr %ptr
39 %bext = sext i16 %b to i64
40 %add = add i64 %a, %bext
44 ; Check the high end of the negative aligned AGH range.
45 define i64 @f4(i64 %a, ptr %src) {
47 ; CHECK: agh %r2, -2(%r3)
49 %ptr = getelementptr i16, ptr %src, i64 -1
50 %b = load i16, ptr %ptr
51 %bext = sext i16 %b to i64
52 %add = add i64 %a, %bext
56 ; Check the low end of the AGH range.
57 define i64 @f5(i64 %a, ptr %src) {
59 ; CHECK: agh %r2, -524288(%r3)
61 %ptr = getelementptr i16, ptr %src, i64 -262144
62 %b = load i16, ptr %ptr
63 %bext = sext i16 %b to i64
64 %add = add i64 %a, %bext
68 ; Check the next word down, which needs separate address logic.
69 ; Other sequences besides this one would be OK.
70 define i64 @f6(i64 %a, ptr %src) {
72 ; CHECK: agfi %r3, -524290
73 ; CHECK: agh %r2, 0(%r3)
75 %ptr = getelementptr i16, ptr %src, i64 -262145
76 %b = load i16, ptr %ptr
77 %bext = sext i16 %b to i64
78 %add = add i64 %a, %bext
82 ; Check that AGH allows an index.
83 define i64 @f7(i64 %a, i64 %src, i64 %index) {
85 ; CHECK: agh %r2, 524284({{%r4,%r3|%r3,%r4}})
87 %add1 = add i64 %src, %index
88 %add2 = add i64 %add1, 524284
89 %ptr = inttoptr i64 %add2 to ptr
90 %b = load i16, ptr %ptr
91 %bext = sext i16 %b to i64
92 %add = add i64 %a, %bext