1 ; Test 64-bit GPR accesses to a PC-relative location.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 @gsrc16 = dso_local global i16 1
6 @gsrc32 = dso_local global i32 1
7 @gsrc64 = dso_local global i64 1
8 @gdst16 = dso_local global i16 2
9 @gdst32 = dso_local global i32 2
10 @gdst64 = dso_local global i64 2
11 @gsrc16u = dso_local global i16 1, align 1, section "foo"
12 @gsrc32u = dso_local global i32 1, align 2, section "foo"
13 @gsrc64u = dso_local global i64 1, align 4, section "foo"
14 @gdst16u = dso_local global i16 2, align 1, section "foo"
15 @gdst32u = dso_local global i32 2, align 2, section "foo"
16 @gdst64u = dso_local global i64 2, align 4, section "foo"
18 ; Check sign-extending loads from i16.
19 define dso_local i64 @f1() {
21 ; CHECK: lghrl %r2, gsrc16
23 %val = load i16, ptr@gsrc16
24 %ext = sext i16 %val to i64
28 ; Check zero-extending loads from i16.
29 define dso_local i64 @f2() {
31 ; CHECK: llghrl %r2, gsrc16
33 %val = load i16, ptr@gsrc16
34 %ext = zext i16 %val to i64
38 ; Check sign-extending loads from i32.
39 define dso_local i64 @f3() {
41 ; CHECK: lgfrl %r2, gsrc32
43 %val = load i32, ptr@gsrc32
44 %ext = sext i32 %val to i64
48 ; Check zero-extending loads from i32.
49 define dso_local i64 @f4() {
51 ; CHECK: llgfrl %r2, gsrc32
53 %val = load i32, ptr@gsrc32
54 %ext = zext i32 %val to i64
58 ; Check truncating 16-bit stores.
59 define dso_local void @f5(i64 %val) {
61 ; CHECK: sthrl %r2, gdst16
63 %half = trunc i64 %val to i16
64 store i16 %half, ptr@gdst16
68 ; Check truncating 32-bit stores.
69 define dso_local void @f6(i64 %val) {
71 ; CHECK: strl %r2, gdst32
73 %word = trunc i64 %val to i32
74 store i32 %word, ptr@gdst32
78 ; Check plain loads and stores.
79 define dso_local void @f7() {
81 ; CHECK: lgrl %r0, gsrc64
82 ; CHECK: stgrl %r0, gdst64
84 %val = load i64, ptr@gsrc64
85 store i64 %val, ptr@gdst64
89 ; Repeat f1 with an unaligned variable.
90 define dso_local i64 @f8() {
92 ; CHECK: lgrl [[REG:%r[0-5]]], gsrc16u@GOT
93 ; CHECK: lgh %r2, 0([[REG]])
95 %val = load i16, ptr@gsrc16u, align 1
96 %ext = sext i16 %val to i64
100 ; Repeat f2 with an unaligned variable.
101 define dso_local i64 @f9() {
103 ; CHECK: lgrl [[REG:%r[0-5]]], gsrc16u@GOT
104 ; CHECK: llgh %r2, 0([[REG]])
106 %val = load i16, ptr@gsrc16u, align 1
107 %ext = zext i16 %val to i64
111 ; Repeat f3 with an unaligned variable.
112 define dso_local i64 @f10() {
114 ; CHECK: larl [[REG:%r[0-5]]], gsrc32u
115 ; CHECK: lgf %r2, 0([[REG]])
117 %val = load i32, ptr@gsrc32u, align 2
118 %ext = sext i32 %val to i64
122 ; Repeat f4 with an unaligned variable.
123 define dso_local i64 @f11() {
125 ; CHECK: larl [[REG:%r[0-5]]], gsrc32u
126 ; CHECK: llgf %r2, 0([[REG]])
128 %val = load i32, ptr@gsrc32u, align 2
129 %ext = zext i32 %val to i64
133 ; Repeat f5 with an unaligned variable.
134 define dso_local void @f12(i64 %val) {
136 ; CHECK: lgrl [[REG:%r[0-5]]], gdst16u@GOT
137 ; CHECK: sth %r2, 0([[REG]])
139 %half = trunc i64 %val to i16
140 store i16 %half, ptr@gdst16u, align 1
144 ; Repeat f6 with an unaligned variable.
145 define dso_local void @f13(i64 %val) {
147 ; CHECK: larl [[REG:%r[0-5]]], gdst32u
148 ; CHECK: st %r2, 0([[REG]])
150 %word = trunc i64 %val to i32
151 store i32 %word, ptr@gdst32u, align 2
155 ; Repeat f7 with unaligned variables.
156 define dso_local void @f14() {
158 ; CHECK: larl [[REG:%r[0-5]]], gsrc64u
159 ; CHECK: lg [[VAL:%r[0-5]]], 0([[REG]])
160 ; CHECK: larl [[REG:%r[0-5]]], gdst64u
161 ; CHECK: stg [[VAL]], 0([[REG]])
163 %val = load i64, ptr@gsrc64u, align 4
164 store i64 %val, ptr@gdst64u, align 4