forked from OSchip/llvm-project
[PowerPC][ctrloop] handles calls in preheader before MTCTRloop
This commit is contained in:
parent
bb095880f8
commit
9cfbe7bbfe
|
@ -108,6 +108,18 @@ bool PPCCTRLoops::runOnMachineFunction(MachineFunction &MF) {
|
|||
}
|
||||
|
||||
bool PPCCTRLoops::isCTRClobber(MachineInstr *MI, bool CheckReads) const {
|
||||
if (!CheckReads) {
|
||||
// If we are only checking for defs, that is we are going to find
|
||||
// definitions before MTCTRloop, for this case:
|
||||
// CTR defination inside the callee of a call instruction will not impact
|
||||
// the defination of MTCTRloop, so we can use definesRegister() for the
|
||||
// check, no need to check the regmask.
|
||||
return (MI->definesRegister(PPC::CTR) &&
|
||||
!MI->registerDefIsDead(PPC::CTR)) ||
|
||||
(MI->definesRegister(PPC::CTR8) &&
|
||||
!MI->registerDefIsDead(PPC::CTR8));
|
||||
}
|
||||
|
||||
if ((MI->modifiesRegister(PPC::CTR) && !MI->registerDefIsDead(PPC::CTR)) ||
|
||||
(MI->modifiesRegister(PPC::CTR8) && !MI->registerDefIsDead(PPC::CTR8)))
|
||||
return true;
|
||||
|
@ -115,9 +127,6 @@ bool PPCCTRLoops::isCTRClobber(MachineInstr *MI, bool CheckReads) const {
|
|||
if (MI->getDesc().isCall())
|
||||
return true;
|
||||
|
||||
if (!CheckReads)
|
||||
return false;
|
||||
|
||||
// We define the CTR in the loop preheader, so if there is any CTR reader in
|
||||
// the loop, we also can not use CTR loop form.
|
||||
if (MI->readsRegister(PPC::CTR) || MI->readsRegister(PPC::CTR8))
|
||||
|
|
|
@ -80,6 +80,58 @@ body: |
|
|||
BLR implicit $lr, implicit $rm
|
||||
...
|
||||
---
|
||||
name: test_fail_call_in_preheader_after_mtctr
|
||||
# CHECK: test_fail_call_in_preheader_after_mtctr
|
||||
tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0.entry:
|
||||
|
||||
%0:gprc = LI 2048
|
||||
; CHECK-NOT: MTCTR
|
||||
; CHECK-NOT: BDNZ
|
||||
; CHECK: ADDI
|
||||
; CHECK: CMPLWI
|
||||
; CHECK: BC
|
||||
MTCTRPseudo killed %0:gprc, implicit-def dead $ctr
|
||||
BL @test_fail_use_in_loop, csr_aix32, implicit-def dead $lr, implicit $rm
|
||||
|
||||
bb.1:
|
||||
|
||||
%1:crbitrc = DecreaseCTRPseudo 1, implicit-def dead $ctr, implicit $ctr
|
||||
BC killed %1:crbitrc, %bb.1
|
||||
B %bb.2
|
||||
|
||||
bb.2:
|
||||
|
||||
BLR implicit $lr, implicit $rm
|
||||
...
|
||||
---
|
||||
name: test_succ_call_in_preheader_before_mtctr
|
||||
# CHECK: test_succ_call_in_preheader_before_mtctr
|
||||
tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0.entry:
|
||||
|
||||
%0:gprc = LI 2048
|
||||
BL @test_fail_use_in_loop, csr_aix32, implicit-def dead $lr, implicit $rm
|
||||
; CHECK: MTCTR
|
||||
; CHECK: BDNZ
|
||||
; CHECK-NOT: ADDI
|
||||
; CHECK-NOT: CMPLWI
|
||||
; CHECK-NOT: BC
|
||||
MTCTRPseudo killed %0:gprc, implicit-def dead $ctr
|
||||
|
||||
bb.1:
|
||||
|
||||
%1:crbitrc = DecreaseCTRPseudo 1, implicit-def dead $ctr, implicit $ctr
|
||||
BC killed %1:crbitrc, %bb.1
|
||||
B %bb.2
|
||||
|
||||
bb.2:
|
||||
|
||||
BLR implicit $lr, implicit $rm
|
||||
...
|
||||
---
|
||||
name: test_fail_call_in_loop
|
||||
# CHECK: test_fail_call_in_loop
|
||||
tracksRegLiveness: true
|
||||
|
|
|
@ -82,6 +82,58 @@ body: |
|
|||
BLR8 implicit $lr8, implicit $rm
|
||||
...
|
||||
---
|
||||
name: test_fail_call_in_preheader_after_mtctr
|
||||
# CHECK: test_fail_call_in_preheader_after_mtctr
|
||||
tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0.entry:
|
||||
|
||||
%0:g8rc = LI8 2048
|
||||
; CHECK-NOT: MTCTR8
|
||||
; CHECK-NOT: BDNZ8
|
||||
; CHECK: ADDI8
|
||||
; CHECK: CMPLDI
|
||||
; CHECK: BC
|
||||
MTCTR8Pseudo killed %0:g8rc, implicit-def dead $ctr8
|
||||
BL8 @test_fail_use_in_loop, csr_ppc64, implicit-def dead $lr8, implicit $rm
|
||||
|
||||
bb.1:
|
||||
|
||||
%1:crbitrc = DecreaseCTR8Pseudo 1, implicit-def dead $ctr8, implicit $ctr8
|
||||
BC killed %1:crbitrc, %bb.1
|
||||
B %bb.2
|
||||
|
||||
bb.2:
|
||||
|
||||
BLR8 implicit $lr8, implicit $rm
|
||||
...
|
||||
---
|
||||
name: test_succ_call_in_preheader_before_mtctr
|
||||
# CHECK: test_succ_call_in_preheader_before_mtctr
|
||||
tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0.entry:
|
||||
|
||||
%0:g8rc = LI8 2048
|
||||
BL8 @test_fail_use_in_loop, csr_ppc64, implicit-def dead $lr8, implicit $rm
|
||||
; CHECK: MTCTR8
|
||||
; CHECK: BDNZ8
|
||||
; CHECK-NOT: ADDI8
|
||||
; CHECK-NOT: CMPLDI
|
||||
; CHECK-NOT: BC
|
||||
MTCTR8Pseudo killed %0:g8rc, implicit-def dead $ctr8
|
||||
|
||||
bb.1:
|
||||
|
||||
%1:crbitrc = DecreaseCTR8Pseudo 1, implicit-def dead $ctr8, implicit $ctr8
|
||||
BC killed %1:crbitrc, %bb.1
|
||||
B %bb.2
|
||||
|
||||
bb.2:
|
||||
|
||||
BLR8 implicit $lr8, implicit $rm
|
||||
...
|
||||
---
|
||||
name: test_fail_call_in_loop
|
||||
# CHECK: test_fail_call_in_loop
|
||||
tracksRegLiveness: true
|
||||
|
|
Loading…
Reference in New Issue