1 ; Test subtractions of a sign-extended i16 from an i64 on z14.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s
7 ; Check SGH with no displacement.
8 define i64 @f1(i64 %a, i16 *%src) {
10 ; CHECK: sgh %r2, 0(%r3)
12 %b = load i16, i16 *%src
13 %bext = sext i16 %b to i64
14 %sub = sub i64 %a, %bext
18 ; Check the high end of the aligned SGH range.
19 define i64 @f2(i64 %a, i16 *%src) {
21 ; CHECK: sgh %r2, 524286(%r3)
23 %ptr = getelementptr i16, i16 *%src, i64 262143
24 %b = load i16, i16 *%ptr
25 %bext = sext i16 %b to i64
26 %sub = sub 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, i16 *%src) {
34 ; CHECK: agfi %r3, 524288
35 ; CHECK: sgh %r2, 0(%r3)
37 %ptr = getelementptr i16, i16 *%src, i64 262144
38 %b = load i16, i16 *%ptr
39 %bext = sext i16 %b to i64
40 %sub = sub i64 %a, %bext
44 ; Check the high end of the negative aligned SGH range.
45 define i64 @f4(i64 %a, i16 *%src) {
47 ; CHECK: sgh %r2, -2(%r3)
49 %ptr = getelementptr i16, i16 *%src, i64 -1
50 %b = load i16, i16 *%ptr
51 %bext = sext i16 %b to i64
52 %sub = sub i64 %a, %bext
56 ; Check the low end of the SGH range.
57 define i64 @f5(i64 %a, i16 *%src) {
59 ; CHECK: sgh %r2, -524288(%r3)
61 %ptr = getelementptr i16, i16 *%src, i64 -262144
62 %b = load i16, i16 *%ptr
63 %bext = sext i16 %b to i64
64 %sub = sub 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, i16 *%src) {
72 ; CHECK: agfi %r3, -524290
73 ; CHECK: sgh %r2, 0(%r3)
75 %ptr = getelementptr i16, i16 *%src, i64 -262145
76 %b = load i16, i16 *%ptr
77 %bext = sext i16 %b to i64
78 %sub = sub i64 %a, %bext
82 ; Check that SGH allows an index.
83 define i64 @f7(i64 %a, i64 %src, i64 %index) {
85 ; CHECK: sgh %r2, 524284({{%r4,%r3|%r3,%r4}})
87 %add1 = add i64 %src, %index
88 %add2 = add i64 %add1, 524284
89 %ptr = inttoptr i64 %add2 to i16 *
90 %b = load i16, i16 *%ptr
91 %bext = sext i16 %b to i64
92 %sub = sub i64 %a, %bext