llvm.org GIT mirror llvm / a6e12b5
[SystemZ] Allow immediate moves to be rematerialized git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185068 91177308-0d34-0410-b5e6-96231b3b80d8 Richard Sandiford 7 years ago
8 changed file(s) with 94 addition(s) and 39 deletion(s). Raw diff Collapse all Expand all
221221 }
222222
223223 // Immediate moves.
224 let neverHasSideEffects = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
224 let neverHasSideEffects = 1, isAsCheapAsAMove = 1, isMoveImm = 1,
225 isReMaterializable = 1 in {
225226 // 16-bit sign-extended immediates.
226227 def LHI : UnaryRI<"lhi", 0xA78, bitconvert, GR32, imm32sx16>;
227228 def LGHI : UnaryRI<"lghi", 0xA79, bitconvert, GR64, imm64sx16>;
475476 // full-width move. (We use IILF rather than something like LLILF
476477 // for 32-bit moves because IILF leaves the upper 32 bits of the
477478 // GR64 unchanged.)
478 let isCodeGenOnly = 1 in {
479 let isCodeGenOnly = 1, isAsCheapAsAMove = 1, isMoveImm = 1,
480 isReMaterializable = 1 in {
479481 def IILF32 : UnaryRIL<"iilf", 0xC09, bitconvert, GR32, uimm32>;
480482 }
481483 def IILF : BinaryRIL<"iilf", 0xC09, insertlf, GR64, imm64lf32>;
1616 ; normally use %f0/%f2 as the first available 128-bit pair. This choice
1717 ; is hard-coded in the FP128 tests.
1818 ;
19 ; The order of the CHECK-INT loads doesn't matter. The same goes for the
20 ; CHECK_FP128-* stores and the CHECK-STACK stores. It would be OK to reorder
19 ; The order of the CHECK-STACK stores doesn't matter. It would be OK to reorder
2120 ; them in response to future code changes.
2221 define void @foo() {
2322 ; CHECK-INT: foo:
24 ; CHECK-INT: lhi %r2, 1
25 ; CHECK-INT: lhi %r3, 2
26 ; CHECK-INT: lhi %r4, 3
27 ; CHECK-INT: lghi %r5, 4
28 ; CHECK-INT: la %r6, {{224|240}}(%r15)
23 ; CHECK-INT-DAG: lhi %r2, 1
24 ; CHECK-INT-DAG: lhi %r3, 2
25 ; CHECK-INT-DAG: lhi %r4, 3
26 ; CHECK-INT-DAG: lghi %r5, 4
27 ; CHECK-INT-DAG: la %r6, {{224|240}}(%r15)
2928 ; CHECK-INT: brasl %r14, bar@PLT
3029 ;
3130 ; CHECK-FLOAT: foo:
4140 ; CHECK-FP128-1: foo:
4241 ; CHECK-FP128-1: aghi %r15, -256
4342 ; CHECK-FP128-1: lzxr %f0
44 ; CHECK-FP128-1: std %f0, 224(%r15)
45 ; CHECK-FP128-1: std %f2, 232(%r15)
43 ; CHECK-FP128-1-DAG: std %f0, 224(%r15)
44 ; CHECK-FP128-1-DAG: std %f2, 232(%r15)
4645 ; CHECK-FP128-1: brasl %r14, bar@PLT
4746 ;
4847 ; CHECK-FP128-2: foo:
4948 ; CHECK-FP128-2: aghi %r15, -256
5049 ; CHECK-FP128-2: lzxr %f0
51 ; CHECK-FP128-2: std %f0, 240(%r15)
52 ; CHECK-FP128-2: std %f2, 248(%r15)
50 ; CHECK-FP128-2-DAG: std %f0, 240(%r15)
51 ; CHECK-FP128-2-DAG: std %f2, 248(%r15)
5352 ; CHECK-FP128-2: brasl %r14, bar@PLT
5453 ;
5554 ; CHECK-STACK: foo:
1717 ; normally use %f0/%f2 as the first available 128-bit pair. This choice
1818 ; is hard-coded in the FP128 tests.
1919 ;
20 ; The order of the CHECK-INT loads doesn't matter. The same goes for the
21 ; CHECK_FP128-* stores and the CHECK-STACK stores. It would be OK to reorder
20 ; The order of the CHECK-STACK stores doesn't matter. It would be OK to reorder
2221 ; them in response to future code changes.
2322 define void @foo() {
2423 ; CHECK-INT: foo:
25 ; CHECK-INT: lghi %r2, -1
26 ; CHECK-INT: lghi %r3, -2
27 ; CHECK-INT: lghi %r4, -3
28 ; CHECK-INT: lghi %r5, -4
29 ; CHECK-INT: la %r6, {{224|240}}(%r15)
24 ; CHECK-INT-DAG: lghi %r2, -1
25 ; CHECK-INT-DAG: lghi %r3, -2
26 ; CHECK-INT-DAG: lghi %r4, -3
27 ; CHECK-INT-DAG: lghi %r5, -4
28 ; CHECK-INT-DAG: la %r6, {{224|240}}(%r15)
3029 ; CHECK-INT: brasl %r14, bar@PLT
3130 ;
3231 ; CHECK-FLOAT: foo:
4241 ; CHECK-FP128-1: foo:
4342 ; CHECK-FP128-1: aghi %r15, -256
4443 ; CHECK-FP128-1: lzxr %f0
45 ; CHECK-FP128-1: std %f0, 224(%r15)
46 ; CHECK-FP128-1: std %f2, 232(%r15)
44 ; CHECK-FP128-1-DAG: std %f0, 224(%r15)
45 ; CHECK-FP128-1-DAG: std %f2, 232(%r15)
4746 ; CHECK-FP128-1: brasl %r14, bar@PLT
4847 ;
4948 ; CHECK-FP128-2: foo:
5049 ; CHECK-FP128-2: aghi %r15, -256
5150 ; CHECK-FP128-2: lzxr %f0
52 ; CHECK-FP128-2: std %f0, 240(%r15)
53 ; CHECK-FP128-2: std %f2, 248(%r15)
51 ; CHECK-FP128-2-DAG: std %f0, 240(%r15)
52 ; CHECK-FP128-2-DAG: std %f2, 248(%r15)
5453 ; CHECK-FP128-2: brasl %r14, bar@PLT
5554 ;
5655 ; CHECK-STACK: foo:
1717 ; normally use %f0/%f2 as the first available 128-bit pair. This choice
1818 ; is hard-coded in the FP128 tests.
1919 ;
20 ; The order of the CHECK-INT loads doesn't matter. The same goes for the
21 ; CHECK_FP128-* stores and the CHECK-STACK stores. It would be OK to reorder
20 ; The order of the CHECK-STACK stores doesn't matter. It would be OK to reorder
2221 ; them in response to future code changes.
2322 define void @foo() {
2423 ; CHECK-INT: foo:
25 ; CHECK-INT: lghi %r2, 255
26 ; CHECK-INT: llill %r3, 65534
27 ; CHECK-INT: llilf %r4, 4294967293
28 ; CHECK-INT: lghi %r5, -4
29 ; CHECK-INT: la %r6, {{224|240}}(%r15)
24 ; CHECK-INT-DAG: lghi %r2, 255
25 ; CHECK-INT-DAG: llill %r3, 65534
26 ; CHECK-INT-DAG: llilf %r4, 4294967293
27 ; CHECK-INT-DAG: lghi %r5, -4
28 ; CHECK-INT-DAG: la %r6, {{224|240}}(%r15)
3029 ; CHECK-INT: brasl %r14, bar@PLT
3130 ;
3231 ; CHECK-FLOAT: foo:
4241 ; CHECK-FP128-1: foo:
4342 ; CHECK-FP128-1: aghi %r15, -256
4443 ; CHECK-FP128-1: lzxr %f0
45 ; CHECK-FP128-1: std %f0, 224(%r15)
46 ; CHECK-FP128-1: std %f2, 232(%r15)
44 ; CHECK-FP128-1-DAG: std %f0, 224(%r15)
45 ; CHECK-FP128-1-DAG: std %f2, 232(%r15)
4746 ; CHECK-FP128-1: brasl %r14, bar@PLT
4847 ;
4948 ; CHECK-FP128-2: foo:
5049 ; CHECK-FP128-2: aghi %r15, -256
5150 ; CHECK-FP128-2: lzxr %f0
52 ; CHECK-FP128-2: std %f0, 240(%r15)
53 ; CHECK-FP128-2: std %f2, 248(%r15)
51 ; CHECK-FP128-2-DAG: std %f0, 240(%r15)
52 ; CHECK-FP128-2-DAG: std %f2, 248(%r15)
5453 ; CHECK-FP128-2: brasl %r14, bar@PLT
5554 ;
5655 ; CHECK-STACK: foo:
155155 ret i32 %res
156156 }
157157
158 ; Check that constants are forced into a register.
158 ; Check that constants are handled.
159159 define i32 @f13(i32 %dummy, i32 *%ptr) {
160160 ; CHECK: f13:
161161 ; CHECK: lhi [[LIMIT:%r[0-9]+]], 42
163163 ; CHECK: [[LOOP:\.[^:]*]]:
164164 ; CHECK: lr [[NEW:%r[0-9]+]], %r2
165165 ; CHECK: crjle %r2, [[LIMIT]], [[KEEP:\..*]]
166 ; CHECK: lr [[NEW]], [[LIMIT]]
166 ; CHECK: lhi [[NEW]], 42
167167 ; CHECK: cs %r2, [[NEW]], 0(%r3)
168168 ; CHECK: jlh [[LOOP]]
169169 ; CHECK: br %r14
122122 ret i64 %res
123123 }
124124
125 ; Check that constants are forced into a register.
125 ; Check that constants are handled.
126126 define i64 @f10(i64 %dummy, i64 *%ptr) {
127127 ; CHECK: f10:
128128 ; CHECK: lghi [[LIMIT:%r[0-9]+]], 42
130130 ; CHECK: [[LOOP:\.[^:]*]]:
131131 ; CHECK: lgr [[NEW:%r[0-9]+]], %r2
132132 ; CHECK: cgrjle %r2, [[LIMIT]], [[KEEP:\..*]]
133 ; CHECK: lgr [[NEW]], [[LIMIT]]
133 ; CHECK: lghi [[NEW]], 42
134134 ; CHECK: csg %r2, [[NEW]], 0(%r3)
135135 ; CHECK: jlh [[LOOP]]
136136 ; CHECK: br %r14
0 ; Test loading of 32-bit constants.
11 ;
22 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
3
4 declare void @foo(i32, i32, i32, i32)
35
46 ; Check 0.
57 define i32 @f1() {
8890 ; CHECK: br %r14
8991 ret i32 -1
9092 }
93
94 ; Check that constant loads are rematerialized.
95 define i32 @f12() {
96 ; CHECK: f12:
97 ; CHECK-DAG: lhi %r2, 42
98 ; CHECK-DAG: llill %r3, 32768
99 ; CHECK-DAG: llilh %r4, 1
100 ; CHECK-DAG: iilf %r5, 65537
101 ; CHECK: brasl %r14, foo@PLT
102 ; CHECK-DAG: lhi %r2, 42
103 ; CHECK-DAG: llill %r3, 32768
104 ; CHECK-DAG: llilh %r4, 1
105 ; CHECK-DAG: iilf %r5, 65537
106 ; CHECK: brasl %r14, foo@PLT
107 ; CHECK: lhi %r2, 42
108 ; CHECK: br %r14
109 call void @foo(i32 42, i32 32768, i32 65536, i32 65537)
110 call void @foo(i32 42, i32 32768, i32 65536, i32 65537)
111 ret i32 42
112 }
0 ; Test loading of 64-bit constants.
11 ;
22 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
3
4 declare void @foo(i64, i64, i64, i64)
35
46 ; Check 0.
57 define i64 @f1() {
248250 ; CHECK-NEXT: br %r14
249251 ret i64 -2147483649
250252 }
253
254 ; Check that constant loads are rematerialized.
255 define i64 @f31() {
256 ; CHECK: f31:
257 ; CHECK-DAG: lghi %r2, 42
258 ; CHECK-DAG: lgfi %r3, 65537
259 ; CHECK-DAG: llilf %r4, 2147483649
260 ; CHECK-DAG: llihf %r5, 65537
261 ; CHECK: brasl %r14, foo@PLT
262 ; CHECK-DAG: llill %r2, 32768
263 ; CHECK-DAG: llilh %r3, 1
264 ; CHECK-DAG: llihl %r4, 1
265 ; CHECK-DAG: llihh %r5, 1
266 ; CHECK: brasl %r14, foo@PLT
267 ; CHECK-DAG: lghi %r2, 42
268 ; CHECK-DAG: lgfi %r3, 65537
269 ; CHECK-DAG: llilf %r4, 2147483649
270 ; CHECK-DAG: llihf %r5, 65537
271 ; CHECK: brasl %r14, foo@PLT
272 ; CHECK-DAG: llill %r2, 32768
273 ; CHECK-DAG: llilh %r3, 1
274 ; CHECK-DAG: llihl %r4, 1
275 ; CHECK-DAG: llihh %r5, 1
276 ; CHECK: brasl %r14, foo@PLT
277 ; CHECK: lghi %r2, 42
278 ; CHECK: br %r14
279 call void @foo(i64 42, i64 65537, i64 2147483649, i64 281479271677952)
280 call void @foo(i64 32768, i64 65536, i64 4294967296, i64 281474976710656)
281 call void @foo(i64 42, i64 65537, i64 2147483649, i64 281479271677952)
282 call void @foo(i64 32768, i64 65536, i64 4294967296, i64 281474976710656)
283 ret i64 42
284 }