blob: a5e74061017e073949992c29de98b216b6cbf231 [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
David Blaikiea79ac142015-02-27 21:17:42 +000038 %word = load i32 , i32 *%src
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000039 %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
David Blaikie79e6c742015-02-27 19:29:02 +000048 %ptr = getelementptr i32, i32 *%src, i64 131071
David Blaikiea79ac142015-02-27 21:17:42 +000049 %word = load i32 , i32 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000050 %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
David Blaikie79e6c742015-02-27 19:29:02 +000061 %ptr = getelementptr i32, i32 *%src, i64 131072
David Blaikiea79ac142015-02-27 21:17:42 +000062 %word = load i32 , i32 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000063 %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
David Blaikie79e6c742015-02-27 19:29:02 +000072 %ptr = getelementptr i32, i32 *%src, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +000073 %word = load i32 , i32 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000074 %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
David Blaikie79e6c742015-02-27 19:29:02 +000083 %ptr = getelementptr i32, i32 *%src, i64 -131072
David Blaikiea79ac142015-02-27 21:17:42 +000084 %word = load i32 , i32 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000085 %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
David Blaikie79e6c742015-02-27 19:29:02 +000096 %ptr = getelementptr i32, i32 *%src, i64 -131073
David Blaikiea79ac142015-02-27 21:17:42 +000097 %word = load i32 , i32 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000098 %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 *
David Blaikiea79ac142015-02-27 21:17:42 +0000110 %word = load i32 , i32 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000111 %ext = zext i32 %word to i64
112 ret i64 %ext
113}