2016-12-02 06:39:51 +08:00
|
|
|
# RUN: llc -mtriple=aarch64-apple-ios -run-pass=simple-register-coalescing %s -o - | FileCheck %s
|
|
|
|
--- |
|
2017-01-14 03:08:36 +08:00
|
|
|
declare void @f2()
|
|
|
|
|
2017-02-07 09:59:39 +08:00
|
|
|
define void @func0() { ret void }
|
|
|
|
define void @func1() { ret void }
|
|
|
|
define void @func2() { ret void }
|
2016-12-02 06:39:51 +08:00
|
|
|
...
|
|
|
|
---
|
|
|
|
# Check coalescing of COPYs from reserved physregs.
|
2017-02-07 09:59:39 +08:00
|
|
|
# CHECK-LABEL: name: func0
|
|
|
|
name: func0
|
2016-12-02 06:39:51 +08:00
|
|
|
body: |
|
|
|
|
bb.0:
|
|
|
|
; We usually should not coalesce copies from allocatable physregs.
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: %0:gpr32 = COPY $w7
|
|
|
|
; CHECK: STRWui %0, $x1, 0
|
|
|
|
%0 : gpr32 = COPY $w7
|
|
|
|
STRWui %0, $x1, 0
|
2016-12-02 06:39:51 +08:00
|
|
|
|
|
|
|
; It is fine to coalesce copies from reserved physregs
|
|
|
|
; CHECK-NOT: COPY
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: STRXui $fp, $x1, 0
|
|
|
|
%1 : gpr64 = COPY $fp
|
|
|
|
STRXui %1, $x1, 0
|
2016-12-02 06:39:51 +08:00
|
|
|
|
|
|
|
; It is not fine to coalesce copies from reserved physregs when they are
|
|
|
|
; clobbered.
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: %2:gpr64 = COPY $fp
|
|
|
|
; CHECK: STRXui %2, $x1, 0
|
|
|
|
%2 : gpr64 = COPY $fp
|
|
|
|
$fp = SUBXri $fp, 4, 0
|
|
|
|
STRXui %2, $x1, 0
|
2016-12-02 06:39:51 +08:00
|
|
|
|
|
|
|
; Is is fine to coalesce copies from constant physregs even when they are
|
|
|
|
; clobbered.
|
|
|
|
; CHECK-NOT: COPY
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: STRWui $wzr, $x1
|
|
|
|
%3 : gpr32 = COPY $wzr
|
|
|
|
dead $wzr = SUBSWri $w1, 0, 0, implicit-def $nzcv
|
|
|
|
STRWui %3, $x1, 0
|
2016-12-02 06:39:51 +08:00
|
|
|
|
|
|
|
; Is is fine to coalesce copies from constant physregs even when they are
|
|
|
|
; clobbered.
|
|
|
|
; CHECK-NOT: COPY
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: STRXui $xzr, $x1
|
|
|
|
%4 : gpr64 = COPY $xzr
|
|
|
|
dead $wzr = SUBSWri $w1, 0, 0, implicit-def $nzcv
|
|
|
|
STRXui %4, $x1, 0
|
2016-12-02 06:39:51 +08:00
|
|
|
|
|
|
|
; Coalescing COPYs into constant physregs.
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: $wzr = SUBSWri $w1, 0, 0
|
|
|
|
%5 : gpr32 = SUBSWri $w1, 0, 0, implicit-def $nzcv
|
|
|
|
$wzr = COPY %5
|
2016-12-02 06:39:51 +08:00
|
|
|
|
|
|
|
; Only coalesce when the source register is reserved as a whole (this is
|
|
|
|
; a limitation of the current code which cannot update liveness information
|
|
|
|
; of the non-reserved part).
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: %6:xseqpairsclass = COPY $x28_fp
|
2016-12-02 06:39:51 +08:00
|
|
|
; CHECK: HINT 0, implicit %6
|
2018-02-01 06:04:26 +08:00
|
|
|
%6 : xseqpairsclass = COPY $x28_fp
|
2016-12-02 06:39:51 +08:00
|
|
|
HINT 0, implicit %6
|
2017-01-14 03:08:36 +08:00
|
|
|
|
|
|
|
; It is not fine to coalesce copies from reserved physregs when they are
|
|
|
|
; clobbered by the regmask on a call.
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: %7:gpr64 = COPY $x18
|
|
|
|
; CHECK: BL @f2, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp
|
|
|
|
; CHECK: STRXui %7, $x1, 0
|
2017-01-14 03:08:36 +08:00
|
|
|
|
|
|
|
; Need a def of x18 so that it's not deduced as "constant".
|
2018-02-01 06:04:26 +08:00
|
|
|
$x18 = COPY $xzr
|
|
|
|
%7 : gpr64 = COPY $x18
|
|
|
|
BL @f2, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp
|
|
|
|
STRXui %7, $x1, 0
|
2017-02-07 09:59:39 +08:00
|
|
|
|
|
|
|
; This can be coalesced.
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: $fp = SUBXri $fp, 4, 0
|
|
|
|
%8 : gpr64sp = SUBXri $fp, 4, 0
|
|
|
|
$fp = COPY %8
|
2017-02-07 09:59:39 +08:00
|
|
|
|
|
|
|
; Cannot coalesce when there are reads of the physreg.
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK-NOT: $fp = SUBXri $fp, 8, 0
|
|
|
|
; CHECK: %9:gpr64sp = SUBXri $fp, 8, 0
|
|
|
|
; CHECK: STRXui $fp, $fp, 0
|
|
|
|
; CHECK: $fp = COPY %9
|
|
|
|
%9 : gpr64sp = SUBXri $fp, 8, 0
|
|
|
|
STRXui $fp, $fp, 0
|
|
|
|
$fp = COPY %9
|
2017-02-07 09:59:39 +08:00
|
|
|
...
|
|
|
|
---
|
|
|
|
# Check coalescing of COPYs from reserved physregs.
|
|
|
|
# CHECK-LABEL: name: func1
|
|
|
|
name: func1
|
|
|
|
body: |
|
|
|
|
bb.0:
|
|
|
|
; Cannot coalesce physreg because we have reads on other CFG paths (we
|
|
|
|
; currently abort for any control flow)
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK-NOT: $fp = SUBXri
|
|
|
|
; CHECK: %0:gpr64sp = SUBXri $fp, 12, 0
|
|
|
|
; CHECK: CBZX undef $x0, %bb.1
|
2017-02-07 09:59:39 +08:00
|
|
|
; CHECK: B %bb.2
|
2018-02-01 06:04:26 +08:00
|
|
|
%0 : gpr64sp = SUBXri $fp, 12, 0
|
|
|
|
CBZX undef $x0, %bb.1
|
2017-02-07 09:59:39 +08:00
|
|
|
B %bb.2
|
|
|
|
|
|
|
|
bb.1:
|
2018-02-01 06:04:26 +08:00
|
|
|
$fp = COPY %0
|
2017-02-07 09:59:39 +08:00
|
|
|
RET_ReallyLR
|
|
|
|
|
|
|
|
bb.2:
|
2018-02-01 06:04:26 +08:00
|
|
|
STRXui $fp, $fp, 0
|
2017-02-07 09:59:39 +08:00
|
|
|
RET_ReallyLR
|
|
|
|
...
|
|
|
|
---
|
|
|
|
# CHECK-LABEL: name: func2
|
|
|
|
name: func2
|
|
|
|
body: |
|
|
|
|
bb.0:
|
|
|
|
; We can coalesce copies from physreg to vreg across multiple blocks.
|
|
|
|
; CHECK-NOT: COPY
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: CBZX undef $x0, %bb.1
|
2017-02-07 09:59:39 +08:00
|
|
|
; CHECK-NEXT: B %bb.2
|
2018-02-01 06:04:26 +08:00
|
|
|
%0 : gpr64sp = COPY $fp
|
|
|
|
CBZX undef $x0, %bb.1
|
2017-02-07 09:59:39 +08:00
|
|
|
B %bb.2
|
|
|
|
|
|
|
|
bb.1:
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK: STRXui undef $x0, $fp, 0
|
2017-02-07 09:59:39 +08:00
|
|
|
; CHECK-NEXT: RET_ReallyLR
|
2018-02-01 06:04:26 +08:00
|
|
|
STRXui undef $x0, %0, 0
|
2017-02-07 09:59:39 +08:00
|
|
|
RET_ReallyLR
|
|
|
|
|
|
|
|
bb.2:
|
|
|
|
RET_ReallyLR
|
2016-12-02 06:39:51 +08:00
|
|
|
...
|