1 ; Test 64-bit GPR accesses to a PC-relative location.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
10 @gdst64 = global i64 2
11 @gsrc16u = global i16 1, align 1, section "foo"
12 @gsrc32u = global i32 1, align 2, section "foo"
13 @gsrc64u = global i64 1, align 4, section "foo"
14 @gdst16u = global i16 2, align 1, section "foo"
15 @gdst32u = global i32 2, align 2, section "foo"
16 @gdst64u = global i64 2, align 4, section "foo"
18 ; Check sign-extending loads from i16.
21 ; CHECK: lghrl %r2, gsrc16
23 %val = load i16, i16 *@gsrc16
24 %ext = sext i16 %val to i64
28 ; Check zero-extending loads from i16.
31 ; CHECK: llghrl %r2, gsrc16
33 %val = load i16, i16 *@gsrc16
34 %ext = zext i16 %val to i64
38 ; Check sign-extending loads from i32.
41 ; CHECK: lgfrl %r2, gsrc32
43 %val = load i32, i32 *@gsrc32
44 %ext = sext i32 %val to i64
48 ; Check zero-extending loads from i32.
51 ; CHECK: llgfrl %r2, gsrc32
53 %val = load i32, i32 *@gsrc32
54 %ext = zext i32 %val to i64
58 ; Check truncating 16-bit stores.
59 define void @f5(i64 %val) {
61 ; CHECK: sthrl %r2, gdst16
63 %half = trunc i64 %val to i16
64 store i16 %half, i16 *@gdst16
68 ; Check truncating 32-bit stores.
69 define void @f6(i64 %val) {
71 ; CHECK: strl %r2, gdst32
73 %word = trunc i64 %val to i32
74 store i32 %word, i32 *@gdst32
78 ; Check plain loads and stores.
81 ; CHECK: lgrl %r0, gsrc64
82 ; CHECK: stgrl %r0, gdst64
84 %val = load i64, i64 *@gsrc64
85 store i64 %val, i64 *@gdst64
89 ; Repeat f1 with an unaligned variable.
92 ; CHECK: lgrl [[REG:%r[0-5]]], gsrc16u@GOT
93 ; CHECK: lgh %r2, 0([[REG]])
95 %val = load i16, i16 *@gsrc16u, align 1
96 %ext = sext i16 %val to i64
100 ; Repeat f2 with an unaligned variable.
103 ; CHECK: lgrl [[REG:%r[0-5]]], gsrc16u@GOT
104 ; CHECK: llgh %r2, 0([[REG]])
106 %val = load i16, i16 *@gsrc16u, align 1
107 %ext = zext i16 %val to i64
111 ; Repeat f3 with an unaligned variable.
114 ; CHECK: larl [[REG:%r[0-5]]], gsrc32u
115 ; CHECK: lgf %r2, 0([[REG]])
117 %val = load i32, i32 *@gsrc32u, align 2
118 %ext = sext i32 %val to i64
122 ; Repeat f4 with an unaligned variable.
125 ; CHECK: larl [[REG:%r[0-5]]], gsrc32u
126 ; CHECK: llgf %r2, 0([[REG]])
128 %val = load i32, i32 *@gsrc32u, align 2
129 %ext = zext i32 %val to i64
133 ; Repeat f5 with an unaligned variable.
134 define 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, i16 *@gdst16u, align 1
144 ; Repeat f6 with an unaligned variable.
145 define 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, i32 *@gdst32u, align 2
155 ; Repeat f7 with unaligned variables.
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, i64 *@gsrc64u, align 4
164 store i64 %val, i64 *@gdst64u, align 4