[llvm] f034c98 - [PowerPC] mark dead def for ctr be clobber.
Chen Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 17 23:05:50 PST 2022
Author: Chen Zheng
Date: 2022-11-18T06:55:42Z
New Revision: f034c98af000f9b1d260bee036ecf653062e1e90
URL: https://github.com/llvm/llvm-project/commit/f034c98af000f9b1d260bee036ecf653062e1e90
DIFF: https://github.com/llvm/llvm-project/commit/f034c98af000f9b1d260bee036ecf653062e1e90.diff
LOG: [PowerPC] mark dead def for ctr be clobber.
TLS pseudo ADDIStlsgdHA will have such def. This dead def should
also prevent PPC from generating CTR loops.
Added:
Modified:
llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
llvm/test/CodeGen/PowerPC/ctrloops64.mir
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
index 87d62f1619bc3..6de366c2bb664 100644
--- a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
+++ b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
@@ -114,14 +114,10 @@ bool PPCCTRLoops::isCTRClobber(MachineInstr *MI, bool CheckReads) const {
// 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));
+ return MI->definesRegister(PPC::CTR) || MI->definesRegister(PPC::CTR8);
}
- if ((MI->modifiesRegister(PPC::CTR) && !MI->registerDefIsDead(PPC::CTR)) ||
- (MI->modifiesRegister(PPC::CTR8) && !MI->registerDefIsDead(PPC::CTR8)))
+ if (MI->modifiesRegister(PPC::CTR) || MI->modifiesRegister(PPC::CTR8))
return true;
if (MI->getDesc().isCall())
diff --git a/llvm/test/CodeGen/PowerPC/ctrloops64.mir b/llvm/test/CodeGen/PowerPC/ctrloops64.mir
index 8e50c555195b1..de37e6accd40e 100644
--- a/llvm/test/CodeGen/PowerPC/ctrloops64.mir
+++ b/llvm/test/CodeGen/PowerPC/ctrloops64.mir
@@ -345,3 +345,30 @@ body: |
BLR8 implicit $lr8, implicit $rm
...
+---
+name: test_fail_dead_def_in_preheader
+# CHECK: test_fail_dead_def_in_preheader
+tracksRegLiveness: true
+body: |
+ bb.0.entry:
+
+ %0:g8rc = LI8 2048
+ %1:g8rc = LI8 1024
+ MTCTR8loop killed %0:g8rc, implicit-def dead $ctr8
+ MTCTR8 killed %1:g8rc, implicit-def dead $ctr8
+ ; CHECK-NOT: MTCTR8loop
+ ; CHECK-NOT: BDNZ8
+ ; CHECK: ADDI8
+ ; CHECK: CMPLDI
+ ; CHECK: BC
+
+ bb.1:
+
+ %2:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
+ BC killed %2:crbitrc, %bb.1
+ B %bb.2
+
+ bb.2:
+
+ BLR8 implicit $lr8, implicit $rm
+...
More information about the llvm-commits
mailing list