blob: f796618dd4f4569c1cc0d8d6e65a2c6e6424ab73 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test that we can use NI for byte operations that are expressed as i32
2; or i64 operations.
3;
4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5
6; Zero extension to 32 bits, negative constant.
7define void @f1(i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +00008; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00009; CHECK: ni 0(%r2), 254
10; CHECK: br %r14
11 %val = load i8 *%ptr
12 %ext = zext i8 %val to i32
13 %and = and i32 %ext, -2
14 %trunc = trunc i32 %and to i8
15 store i8 %trunc, i8 *%ptr
16 ret void
17}
18
19; Zero extension to 64 bits, negative constant.
20define void @f2(i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000021; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000022; CHECK: ni 0(%r2), 254
23; CHECK: br %r14
24 %val = load i8 *%ptr
25 %ext = zext i8 %val to i64
26 %and = and i64 %ext, -2
27 %trunc = trunc i64 %and to i8
28 store i8 %trunc, i8 *%ptr
29 ret void
30}
31
32; Zero extension to 32 bits, positive constant.
33define void @f3(i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000034; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000035; CHECK: ni 0(%r2), 254
36; CHECK: br %r14
37 %val = load i8 *%ptr
38 %ext = zext i8 %val to i32
39 %and = and i32 %ext, 254
40 %trunc = trunc i32 %and to i8
41 store i8 %trunc, i8 *%ptr
42 ret void
43}
44
45; Zero extension to 64 bits, positive constant.
46define void @f4(i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000047; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000048; CHECK: ni 0(%r2), 254
49; CHECK: br %r14
50 %val = load i8 *%ptr
51 %ext = zext i8 %val to i64
52 %and = and i64 %ext, 254
53 %trunc = trunc i64 %and to i8
54 store i8 %trunc, i8 *%ptr
55 ret void
56}
57
58; Sign extension to 32 bits, negative constant.
59define void @f5(i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000060; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000061; CHECK: ni 0(%r2), 254
62; CHECK: br %r14
63 %val = load i8 *%ptr
64 %ext = sext i8 %val to i32
65 %and = and i32 %ext, -2
66 %trunc = trunc i32 %and to i8
67 store i8 %trunc, i8 *%ptr
68 ret void
69}
70
71; Sign extension to 64 bits, negative constant.
72define void @f6(i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000073; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000074; CHECK: ni 0(%r2), 254
75; CHECK: br %r14
76 %val = load i8 *%ptr
77 %ext = sext i8 %val to i64
78 %and = and i64 %ext, -2
79 %trunc = trunc i64 %and to i8
80 store i8 %trunc, i8 *%ptr
81 ret void
82}
83
84; Sign extension to 32 bits, positive constant.
85define void @f7(i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000086; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000087; CHECK: ni 0(%r2), 254
88; CHECK: br %r14
89 %val = load i8 *%ptr
90 %ext = sext i8 %val to i32
91 %and = and i32 %ext, 254
92 %trunc = trunc i32 %and to i8
93 store i8 %trunc, i8 *%ptr
94 ret void
95}
96
97; Sign extension to 64 bits, positive constant.
98define void @f8(i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000099; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000100; CHECK: ni 0(%r2), 254
101; CHECK: br %r14
102 %val = load i8 *%ptr
103 %ext = sext i8 %val to i64
104 %and = and i64 %ext, 254
105 %trunc = trunc i64 %and to i8
106 store i8 %trunc, i8 *%ptr
107 ret void
108}