blob: 781c74c7fa2341bb5bfe2e584d17b4d05186af68 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test zero extensions from an i32 to an i64.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Test register extension, starting with an i32.
6define i64 @f1(i32 %a) {
Stephen Lind24ab202013-07-14 06:24:09 +00007; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00008; CHECK: llgfr %r2, %r2
Richard Sandifordec8693d2013-06-27 09:49:34 +00009; CHECK: br %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000010 %ext = zext i32 %a to i64
11 ret i64 %ext
12}
13
14; ...and again with an i64.
15define i64 @f2(i64 %a) {
Stephen Lind24ab202013-07-14 06:24:09 +000016; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000017; CHECK: llgfr %r2, %r2
Richard Sandifordec8693d2013-06-27 09:49:34 +000018; CHECK: br %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000019 %word = trunc i64 %a to i32
20 %ext = zext i32 %word to i64
21 ret i64 %ext
22}
23
24; Check ANDs that are equivalent to zero extension.
25define i64 @f3(i64 %a) {
Stephen Lind24ab202013-07-14 06:24:09 +000026; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000027; CHECK: llgfr %r2, %r2
Richard Sandifordec8693d2013-06-27 09:49:34 +000028; CHECK: br %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000029 %ext = and i64 %a, 4294967295
30 ret i64 %ext
31}
32
33; Check LLGF with no displacement.
34define i64 @f4(i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000035; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000036; CHECK: llgf %r2, 0(%r2)
37; CHECK: br %r14
38 %word = load i32 *%src
39 %ext = zext i32 %word to i64
40 ret i64 %ext
41}
42
43; Check the high end of the LLGF range.
44define i64 @f5(i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000045; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000046; CHECK: llgf %r2, 524284(%r2)
47; CHECK: br %r14
48 %ptr = getelementptr i32 *%src, i64 131071
49 %word = load i32 *%ptr
50 %ext = zext i32 %word to i64
51 ret i64 %ext
52}
53
54; Check the next word up, which needs separate address logic.
55; Other sequences besides this one would be OK.
56define i64 @f6(i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000057; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000058; CHECK: agfi %r2, 524288
59; CHECK: llgf %r2, 0(%r2)
60; CHECK: br %r14
61 %ptr = getelementptr i32 *%src, i64 131072
62 %word = load i32 *%ptr
63 %ext = zext i32 %word to i64
64 ret i64 %ext
65}
66
67; Check the high end of the negative LLGF range.
68define i64 @f7(i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000069; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000070; CHECK: llgf %r2, -4(%r2)
71; CHECK: br %r14
72 %ptr = getelementptr i32 *%src, i64 -1
73 %word = load i32 *%ptr
74 %ext = zext i32 %word to i64
75 ret i64 %ext
76}
77
78; Check the low end of the LLGF range.
79define i64 @f8(i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000080; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000081; CHECK: llgf %r2, -524288(%r2)
82; CHECK: br %r14
83 %ptr = getelementptr i32 *%src, i64 -131072
84 %word = load i32 *%ptr
85 %ext = zext i32 %word to i64
86 ret i64 %ext
87}
88
89; Check the next word down, which needs separate address logic.
90; Other sequences besides this one would be OK.
91define i64 @f9(i32 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +000092; CHECK-LABEL: f9:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000093; CHECK: agfi %r2, -524292
94; CHECK: llgf %r2, 0(%r2)
95; CHECK: br %r14
96 %ptr = getelementptr i32 *%src, i64 -131073
97 %word = load i32 *%ptr
98 %ext = zext i32 %word to i64
99 ret i64 %ext
100}
101
102; Check that LLGF allows an index.
103define i64 @f10(i64 %src, i64 %index) {
Stephen Lind24ab202013-07-14 06:24:09 +0000104; CHECK-LABEL: f10:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000105; CHECK: llgf %r2, 524287(%r3,%r2)
106; CHECK: br %r14
107 %add1 = add i64 %src, %index
108 %add2 = add i64 %add1, 524287
109 %ptr = inttoptr i64 %add2 to i32 *
110 %word = load i32 *%ptr
111 %ext = zext i32 %word to i64
112 ret i64 %ext
113}