Skip to content

Commit 266a784

Browse files
authored
[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`.
1 parent 26098fe commit 266a784

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

llvm/lib/Target/PowerPC/PPCMIPeephole.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,10 @@ bool PPCMIPeephole::simplifyCode() {
12911291
addRegToUpdate(OrigOp1Reg);
12921292
if (MI.getOperand(1).isReg())
12931293
addRegToUpdate(MI.getOperand(1).getReg());
1294+
if (ToErase && ToErase->getOperand(1).isReg())
1295+
for (auto UseReg : ToErase->explicit_uses())
1296+
if (UseReg.isReg())
1297+
addRegToUpdate(UseReg.getReg());
12941298
++NumRotatesCollapsed;
12951299
}
12961300
break;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# RUN: llc -mtriple=powerpc-ibm-aix -verify-machineinstrs -run-pass=ppc-mi-peepholes -o - %s | FileCheck %s
2+
# RUN: llc -mtriple=powerpc64-ibm-aix -verify-machineinstrs -run-pass=ppc-mi-peepholes -o - %s | FileCheck %s
3+
# RUN: llc -mtriple=powerpc64-linux-gnu -verify-machineinstrs -run-pass=ppc-mi-peepholes -o - %s | FileCheck %s
4+
---
5+
6+
name: testFoldRLWINM
7+
tracksRegLiveness: true
8+
9+
body: |
10+
bb.0.entry:
11+
liveins: $r3
12+
%0:gprc = COPY $r3
13+
B %bb.1
14+
bb.1:
15+
B %bb.2
16+
bb.2:
17+
%1:gprc = RLWINM killed %0:gprc, 1, 0, 30
18+
%2:gprc = RLWINM killed %1:gprc, 31, 0, 0
19+
BLR8 implicit $lr8, implicit $rm
20+
21+
...
22+
23+
# CHECK-LABEL: testFoldRLWINM
24+
# CHECK: bb.0.entry:
25+
# CHECK: dead %0:gprc = COPY killed $r3
26+
# CHECK: bb.2:
27+
# CHECK: dead %2:gprc = LI 0

0 commit comments

Comments
 (0)