[llvm] 74e7729 - [PowerPC] fixup killed flags for ri + addi to ri transformation
Chen Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 7 19:04:42 PDT 2021
Author: Chen Zheng
Date: 2021-04-07T22:04:08-04:00
New Revision: 74e77295e75412ddba74c16d0f0766dfb5b67e89
URL: https://github.com/llvm/llvm-project/commit/74e77295e75412ddba74c16d0f0766dfb5b67e89
DIFF: https://github.com/llvm/llvm-project/commit/74e77295e75412ddba74c16d0f0766dfb5b67e89.diff
LOG: [PowerPC] fixup killed flags for ri + addi to ri transformation
Fixup killed flags if DefMI and MI are not in the same basic blocks.
Reviewed By: nemanjai
Differential Revision: https://reviews.llvm.org/D100023
Added:
Modified:
llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
llvm/test/CodeGen/PowerPC/convert-ri-addi-to-ri.mir
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
index 6887f098ba1bf..155b22f5630bc 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -4744,7 +4744,12 @@ bool PPCInstrInfo::transformToNewImmFormFedByAdd(
LLVM_DEBUG(DefMI.dump());
MI.getOperand(III.OpNoForForwarding).setReg(RegMO->getReg());
- MI.getOperand(III.OpNoForForwarding).setIsKill(RegMO->isKill());
+ if (RegMO->isKill()) {
+ MI.getOperand(III.OpNoForForwarding).setIsKill(true);
+ // Clear the killed flag in RegMO. Doing this here can handle some cases
+ // that DefMI and MI are not in same basic block.
+ RegMO->setIsKill(false);
+ }
MI.getOperand(III.ImmOpNo).setImm(Imm);
// FIXME: fix kill/dead flag if MI and DefMI are not in same basic block.
diff --git a/llvm/test/CodeGen/PowerPC/convert-ri-addi-to-ri.mir b/llvm/test/CodeGen/PowerPC/convert-ri-addi-to-ri.mir
index 80b813c16bfa7..3a1a131af51e6 100644
--- a/llvm/test/CodeGen/PowerPC/convert-ri-addi-to-ri.mir
+++ b/llvm/test/CodeGen/PowerPC/convert-ri-addi-to-ri.mir
@@ -65,3 +65,35 @@ body: |
$x3 = COPY %5:g8rc
BLR8 implicit $lr8, implicit $rm, implicit $x3
...
+---
+name: killFlagSameBlock
+#CHECK : name : killFlagSameBlock
+tracksRegLiveness: true
+body: |
+ bb.0.entry:
+ liveins: $x3
+ %0:g8rc_and_g8rc_nox0 = COPY $x3
+ %1:g8rc_and_g8rc_nox0 = ADDI8 killed %0:g8rc_and_g8rc_nox0, -8
+ ; CHECK: %1:g8rc_and_g8rc_nox0 = ADDI8 %0, -8
+ %2:g8rc = LI8 0
+ ; CHECK: STD killed %2, 8, killed %0
+ STD killed %2:g8rc, 16, %1:g8rc_and_g8rc_nox0
+ BLR8 implicit $lr8, implicit $rm
+...
+---
+name: killFlagDifferentBlocks
+#CHECK : name : killFlagDifferentBlocks
+tracksRegLiveness: true
+body: |
+ bb.0.entry:
+ liveins: $x3
+ %0:g8rc_and_g8rc_nox0 = COPY $x3
+ ; CHECK: %1:g8rc_and_g8rc_nox0 = ADDI8 %0, -8
+ %1:g8rc_and_g8rc_nox0 = ADDI8 killed %0:g8rc_and_g8rc_nox0, -8
+
+ bb.1:
+ %2:g8rc = LI8 0
+ ; CHECK: STD killed %2, 8, killed %0
+ STD killed %2:g8rc, 16, %1:g8rc_and_g8rc_nox0
+ BLR8 implicit $lr8, implicit $rm
+...
More information about the llvm-commits
mailing list