1 ; Test 31-to-64 bit zero extensions.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Test register extension, starting with an i64.
6 define i64 @f1(i64 %a) {
8 ; CHECK: llgtr %r2, %r2
10 %ext = and i64 %a, 2147483647
14 ; Test register extension, starting with an i32.
15 define i64 @f2(i32 %a) {
17 ; CHECK: llgtr %r2, %r2
19 %and = and i32 %a, 2147483647
20 %ext = zext i32 %and to i64
24 ; ... and the other way around.
25 define i64 @f3(i32 %a) {
27 ; CHECK: llgtr %r2, %r2
29 %ext = zext i32 %a to i64
30 %and = and i64 %ext, 2147483647
34 ; Check LLGT with no displacement.
35 define i64 @f4(i32 *%src) {
37 ; CHECK: llgt %r2, 0(%r2)
39 %word = load i32, i32 *%src
40 %ext = zext i32 %word to i64
41 %and = and i64 %ext, 2147483647
45 ; ... and the other way around.
46 define i64 @f5(i32 *%src) {
48 ; CHECK: llgt %r2, 0(%r2)
50 %word = load i32, i32 *%src
51 %and = and i32 %word, 2147483647
52 %ext = zext i32 %and to i64
56 ; Check the high end of the LLGT range.
57 define i64 @f6(i32 *%src) {
59 ; CHECK: llgt %r2, 524284(%r2)
61 %ptr = getelementptr i32, i32 *%src, i64 131071
62 %word = load i32, i32 *%ptr
63 %ext = zext i32 %word to i64
64 %and = and i64 %ext, 2147483647
68 ; Check the next word up, which needs separate address logic.
69 ; Other sequences besides this one would be OK.
70 define i64 @f7(i32 *%src) {
72 ; CHECK: agfi %r2, 524288
73 ; CHECK: llgt %r2, 0(%r2)
75 %ptr = getelementptr i32, i32 *%src, i64 131072
76 %word = load i32, i32 *%ptr
77 %ext = zext i32 %word to i64
78 %and = and i64 %ext, 2147483647
82 ; Check the high end of the negative LLGT range.
83 define i64 @f8(i32 *%src) {
85 ; CHECK: llgt %r2, -4(%r2)
87 %ptr = getelementptr i32, i32 *%src, i64 -1
88 %word = load i32, i32 *%ptr
89 %ext = zext i32 %word to i64
90 %and = and i64 %ext, 2147483647
94 ; Check the low end of the LLGT range.
95 define i64 @f9(i32 *%src) {
97 ; CHECK: llgt %r2, -524288(%r2)
99 %ptr = getelementptr i32, i32 *%src, i64 -131072
100 %word = load i32, i32 *%ptr
101 %ext = zext i32 %word to i64
102 %and = and i64 %ext, 2147483647
106 ; Check the next word down, which needs separate address logic.
107 ; Other sequences besides this one would be OK.
108 define i64 @f10(i32 *%src) {
110 ; CHECK: agfi %r2, -524292
111 ; CHECK: llgt %r2, 0(%r2)
113 %ptr = getelementptr i32, i32 *%src, i64 -131073
114 %word = load i32, i32 *%ptr
115 %ext = zext i32 %word to i64
116 %and = and i64 %ext, 2147483647
120 ; Check that LLGT allows an index.
121 define i64 @f11(i64 %src, i64 %index) {
123 ; CHECK: llgt %r2, 524287(%r3,%r2)
125 %add1 = add i64 %src, %index
126 %add2 = add i64 %add1, 524287
127 %ptr = inttoptr i64 %add2 to i32 *
128 %word = load i32, i32 *%ptr
129 %ext = zext i32 %word to i64
130 %and = and i64 %ext, 2147483647