Skip to content

Commit b62eb3a

Browse files
committed
PeepholeOpt: Do not skip reg_sequence sources with subregs
Contrary to the comment, this particular code is not responsible for handling any composes that may be required, and unhandled cases are already rejected later. Lift this restriction to permit composes and reg_sequence subregisters later.
1 parent d21fc58 commit b62eb3a

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

llvm/lib/CodeGen/PeepholeOptimizer.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,7 @@ class RegSequenceRewriter : public Rewriter {
406406

407407
const MachineOperand &MOInsertedReg = CopyLike.getOperand(CurrentSrcIdx);
408408
Src.Reg = MOInsertedReg.getReg();
409-
// If we have to compose sub-register indices, bail out.
410-
if ((Src.SubReg = MOInsertedReg.getSubReg()))
411-
return false;
409+
Src.SubReg = MOInsertedReg.getSubReg();
412410

413411
// We want to track something that is compatible with the related
414412
// partial definition.

llvm/test/CodeGen/AMDGPU/peephole-opt-regseq-removal.mir

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ body: |
2222
; GCN-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
2323
; GCN-NEXT: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
2424
; GCN-NEXT: [[REG_SEQUENCE:%[0-9]+]]:vreg_64 = REG_SEQUENCE [[COPY]], %subreg.sub0, [[COPY1]], %subreg.sub1
25-
; GCN-NEXT: [[REG_SEQUENCE1:%[0-9]+]]:vreg_64 = REG_SEQUENCE [[REG_SEQUENCE]].sub1, %subreg.sub0, [[REG_SEQUENCE]].sub0, %subreg.sub1
26-
; GCN-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY [[REG_SEQUENCE]].sub1
27-
; GCN-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY [[REG_SEQUENCE]].sub0
25+
; GCN-NEXT: [[REG_SEQUENCE1:%[0-9]+]]:vreg_64 = REG_SEQUENCE [[COPY1]], %subreg.sub0, [[COPY]], %subreg.sub1
26+
; GCN-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY [[COPY1]]
27+
; GCN-NEXT: [[COPY3:%[0-9]+]]:vgpr_32 = COPY [[COPY]]
2828
; GCN-NEXT: KILL [[COPY3]], implicit [[COPY2]]
2929
%0:vgpr_32 = COPY $vgpr0
3030
%1:vgpr_32 = COPY $vgpr1

0 commit comments

Comments
 (0)