1 ; Test zero extensions from an i32 to an i64.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Test register extension, starting with an i32.
6 define i64 @f1(i32 %a) {
8 ; CHECK: llgfr %r2, %r2
10 %ext = zext i32 %a to i64
14 ; ...and again with an i64.
15 define i64 @f2(i64 %a) {
17 ; CHECK: llgfr %r2, %r2
19 %word = trunc i64 %a to i32
20 %ext = zext i32 %word to i64
24 ; Check ANDs that are equivalent to zero extension.
25 define i64 @f3(i64 %a) {
27 ; CHECK: llgfr %r2, %r2
29 %ext = and i64 %a, 4294967295
33 ; Check LLGF with no displacement.
34 define i64 @f4(i32 *%src) {
36 ; CHECK: llgf %r2, 0(%r2)
38 %word = load i32, i32 *%src
39 %ext = zext i32 %word to i64
43 ; Check the high end of the LLGF range.
44 define i64 @f5(i32 *%src) {
46 ; CHECK: llgf %r2, 524284(%r2)
48 %ptr = getelementptr i32, i32 *%src, i64 131071
49 %word = load i32, i32 *%ptr
50 %ext = zext i32 %word to i64
54 ; Check the next word up, which needs separate address logic.
55 ; Other sequences besides this one would be OK.
56 define i64 @f6(i32 *%src) {
58 ; CHECK: agfi %r2, 524288
59 ; CHECK: llgf %r2, 0(%r2)
61 %ptr = getelementptr i32, i32 *%src, i64 131072
62 %word = load i32, i32 *%ptr
63 %ext = zext i32 %word to i64
67 ; Check the high end of the negative LLGF range.
68 define i64 @f7(i32 *%src) {
70 ; CHECK: llgf %r2, -4(%r2)
72 %ptr = getelementptr i32, i32 *%src, i64 -1
73 %word = load i32, i32 *%ptr
74 %ext = zext i32 %word to i64
78 ; Check the low end of the LLGF range.
79 define i64 @f8(i32 *%src) {
81 ; CHECK: llgf %r2, -524288(%r2)
83 %ptr = getelementptr i32, i32 *%src, i64 -131072
84 %word = load i32, i32 *%ptr
85 %ext = zext i32 %word to i64
89 ; Check the next word down, which needs separate address logic.
90 ; Other sequences besides this one would be OK.
91 define i64 @f9(i32 *%src) {
93 ; CHECK: agfi %r2, -524292
94 ; CHECK: llgf %r2, 0(%r2)
96 %ptr = getelementptr i32, i32 *%src, i64 -131073
97 %word = load i32, i32 *%ptr
98 %ext = zext i32 %word to i64
102 ; Check that LLGF allows an index.
103 define i64 @f10(i64 %src, i64 %index) {
105 ; CHECK: llgf %r2, 524287(%r3,%r2)
107 %add1 = add i64 %src, %index
108 %add2 = add i64 %add1, 524287
109 %ptr = inttoptr i64 %add2 to i32 *
110 %word = load i32, i32 *%ptr
111 %ext = zext i32 %word to i64