[llvm] 266a784 - [PowerPC] Ensure MI peephole knows about instr modified by combineRLWINM() (#97134)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 16 08:46:41 PDT 2024
Author: Lei Huang
Date: 2024-07-16T11:46:37-04:00
New Revision: 266a784cce959d475d3d79a877f0c5f39194a4c4
URL: https://github.com/llvm/llvm-project/commit/266a784cce959d475d3d79a877f0c5f39194a4c4
DIFF: https://github.com/llvm/llvm-project/commit/266a784cce959d475d3d79a877f0c5f39194a4c4.diff
LOG: [PowerPC] Ensure MI peephole knows about instr modified by combineRLWINM() (#97134)
Ensure registers used in instructions modified by `combineRLWINM()` are
added to list of `RegsToUpdate`.
Added:
llvm/test/CodeGen/PowerPC/peephole-combineRLWINM-liveness.mir
Modified:
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp b/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
index 535a54a1a9a3c..b8abee76cdfa8 100644
--- a/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
+++ b/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
@@ -1291,6 +1291,10 @@ bool PPCMIPeephole::simplifyCode() {
addRegToUpdate(OrigOp1Reg);
if (MI.getOperand(1).isReg())
addRegToUpdate(MI.getOperand(1).getReg());
+ if (ToErase && ToErase->getOperand(1).isReg())
+ for (auto UseReg : ToErase->explicit_uses())
+ if (UseReg.isReg())
+ addRegToUpdate(UseReg.getReg());
++NumRotatesCollapsed;
}
break;
diff --git a/llvm/test/CodeGen/PowerPC/peephole-combineRLWINM-liveness.mir b/llvm/test/CodeGen/PowerPC/peephole-combineRLWINM-liveness.mir
new file mode 100644
index 0000000000000..a5714f20f77f8
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/peephole-combineRLWINM-liveness.mir
@@ -0,0 +1,27 @@
+# RUN: llc -mtriple=powerpc-ibm-aix -verify-machineinstrs -run-pass=ppc-mi-peepholes -o - %s | FileCheck %s
+# RUN: llc -mtriple=powerpc64-ibm-aix -verify-machineinstrs -run-pass=ppc-mi-peepholes -o - %s | FileCheck %s
+# RUN: llc -mtriple=powerpc64-linux-gnu -verify-machineinstrs -run-pass=ppc-mi-peepholes -o - %s | FileCheck %s
+---
+
+name: testFoldRLWINM
+tracksRegLiveness: true
+
+body: |
+ bb.0.entry:
+ liveins: $r3
+ %0:gprc = COPY $r3
+ B %bb.1
+ bb.1:
+ B %bb.2
+ bb.2:
+ %1:gprc = RLWINM killed %0:gprc, 1, 0, 30
+ %2:gprc = RLWINM killed %1:gprc, 31, 0, 0
+ BLR8 implicit $lr8, implicit $rm
+
+...
+
+# CHECK-LABEL: testFoldRLWINM
+# CHECK: bb.0.entry:
+# CHECK: dead %0:gprc = COPY killed $r3
+# CHECK: bb.2:
+# CHECK: dead %2:gprc = LI 0
More information about the llvm-commits
mailing list