1 ; Test 32-bit ANDs in which the second operand is variable.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
8 define i32 @f1(i32 %a, i32 %b) {
16 ; Check the low end of the N range.
17 define i32 @f2(i32 %a, i32 *%src) {
19 ; CHECK: n %r2, 0(%r3)
26 ; Check the high end of the aligned N range.
27 define i32 @f3(i32 %a, i32 *%src) {
29 ; CHECK: n %r2, 4092(%r3)
31 %ptr = getelementptr i32 *%src, i64 1023
37 ; Check the next word up, which should use NY instead of N.
38 define i32 @f4(i32 %a, i32 *%src) {
40 ; CHECK: ny %r2, 4096(%r3)
42 %ptr = getelementptr i32 *%src, i64 1024
48 ; Check the high end of the aligned NY range.
49 define i32 @f5(i32 %a, i32 *%src) {
51 ; CHECK: ny %r2, 524284(%r3)
53 %ptr = getelementptr i32 *%src, i64 131071
59 ; Check the next word up, which needs separate address logic.
60 ; Other sequences besides this one would be OK.
61 define i32 @f6(i32 %a, i32 *%src) {
63 ; CHECK: agfi %r3, 524288
64 ; CHECK: n %r2, 0(%r3)
66 %ptr = getelementptr i32 *%src, i64 131072
72 ; Check the high end of the negative aligned NY range.
73 define i32 @f7(i32 %a, i32 *%src) {
75 ; CHECK: ny %r2, -4(%r3)
77 %ptr = getelementptr i32 *%src, i64 -1
83 ; Check the low end of the NY range.
84 define i32 @f8(i32 %a, i32 *%src) {
86 ; CHECK: ny %r2, -524288(%r3)
88 %ptr = getelementptr i32 *%src, i64 -131072
94 ; Check the next word down, which needs separate address logic.
95 ; Other sequences besides this one would be OK.
96 define i32 @f9(i32 %a, i32 *%src) {
98 ; CHECK: agfi %r3, -524292
99 ; CHECK: n %r2, 0(%r3)
101 %ptr = getelementptr i32 *%src, i64 -131073
103 %and = and i32 %a, %b
107 ; Check that N allows an index.
108 define i32 @f10(i32 %a, i64 %src, i64 %index) {
110 ; CHECK: n %r2, 4092({{%r4,%r3|%r3,%r4}})
112 %add1 = add i64 %src, %index
113 %add2 = add i64 %add1, 4092
114 %ptr = inttoptr i64 %add2 to i32 *
116 %and = and i32 %a, %b
120 ; Check that NY allows an index.
121 define i32 @f11(i32 %a, i64 %src, i64 %index) {
123 ; CHECK: ny %r2, 4096({{%r4,%r3|%r3,%r4}})
125 %add1 = add i64 %src, %index
126 %add2 = add i64 %add1, 4096
127 %ptr = inttoptr i64 %add2 to i32 *
129 %and = and i32 %a, %b
133 ; Check that ANDs of spilled values can use N rather than NR.
134 define i32 @f12(i32 *%ptr0) {
136 ; CHECK: brasl %r14, foo@PLT
137 ; CHECK: n %r2, 16{{[04]}}(%r15)
139 %ptr1 = getelementptr i32 *%ptr0, i64 2
140 %ptr2 = getelementptr i32 *%ptr0, i64 4
141 %ptr3 = getelementptr i32 *%ptr0, i64 6
142 %ptr4 = getelementptr i32 *%ptr0, i64 8
143 %ptr5 = getelementptr i32 *%ptr0, i64 10
144 %ptr6 = getelementptr i32 *%ptr0, i64 12
145 %ptr7 = getelementptr i32 *%ptr0, i64 14
146 %ptr8 = getelementptr i32 *%ptr0, i64 16
147 %ptr9 = getelementptr i32 *%ptr0, i64 18
149 %val0 = load i32 *%ptr0
150 %val1 = load i32 *%ptr1
151 %val2 = load i32 *%ptr2
152 %val3 = load i32 *%ptr3
153 %val4 = load i32 *%ptr4
154 %val5 = load i32 *%ptr5
155 %val6 = load i32 *%ptr6
156 %val7 = load i32 *%ptr7
157 %val8 = load i32 *%ptr8
158 %val9 = load i32 *%ptr9
160 %ret = call i32 @foo()
162 %and0 = and i32 %ret, %val0
163 %and1 = and i32 %and0, %val1
164 %and2 = and i32 %and1, %val2
165 %and3 = and i32 %and2, %val3
166 %and4 = and i32 %and3, %val4
167 %and5 = and i32 %and4, %val5
168 %and6 = and i32 %and5, %val6
169 %and7 = and i32 %and6, %val7
170 %and8 = and i32 %and7, %val8
171 %and9 = and i32 %and8, %val9