1 ; Test sign 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) {
10 %ext = sext i32 %a to i64
14 ; ...and again with an i64.
15 define i64 @f2(i64 %a) {
17 ; CHECK: lgfr %r2, %r2
19 %word = trunc i64 %a to i32
20 %ext = sext i32 %word to i64
24 ; Check LGF with no displacement.
25 define i64 @f3(ptr %src) {
27 ; CHECK: lgf %r2, 0(%r2)
29 %word = load i32, ptr %src
30 %ext = sext i32 %word to i64
34 ; Check the high end of the LGF range.
35 define i64 @f4(ptr %src) {
37 ; CHECK: lgf %r2, 524284(%r2)
39 %ptr = getelementptr i32, ptr %src, i64 131071
40 %word = load i32, ptr %ptr
41 %ext = sext i32 %word to i64
45 ; Check the next word up, which needs separate address logic.
46 ; Other sequences besides this one would be OK.
47 define i64 @f5(ptr %src) {
49 ; CHECK: agfi %r2, 524288
50 ; CHECK: lgf %r2, 0(%r2)
52 %ptr = getelementptr i32, ptr %src, i64 131072
53 %word = load i32, ptr %ptr
54 %ext = sext i32 %word to i64
58 ; Check the high end of the negative LGF range.
59 define i64 @f6(ptr %src) {
61 ; CHECK: lgf %r2, -4(%r2)
63 %ptr = getelementptr i32, ptr %src, i64 -1
64 %word = load i32, ptr %ptr
65 %ext = sext i32 %word to i64
69 ; Check the low end of the LGF range.
70 define i64 @f7(ptr %src) {
72 ; CHECK: lgf %r2, -524288(%r2)
74 %ptr = getelementptr i32, ptr %src, i64 -131072
75 %word = load i32, ptr %ptr
76 %ext = sext i32 %word to i64
80 ; Check the next word down, which needs separate address logic.
81 ; Other sequences besides this one would be OK.
82 define i64 @f8(ptr %src) {
84 ; CHECK: agfi %r2, -524292
85 ; CHECK: lgf %r2, 0(%r2)
87 %ptr = getelementptr i32, ptr %src, i64 -131073
88 %word = load i32, ptr %ptr
89 %ext = sext i32 %word to i64
93 ; Check that LGF allows an index.
94 define i64 @f9(i64 %src, i64 %index) {
96 ; CHECK: lgf %r2, 524287(%r3,%r2)
98 %add1 = add i64 %src, %index
99 %add2 = add i64 %add1, 524287
100 %ptr = inttoptr i64 %add2 to ptr
101 %word = load i32, ptr %ptr
102 %ext = sext i32 %word to i64