[PATCH] D125657: [RegisterCoalescer] fix dst subreg replacement during remat copy trick
Afanasyev Ivan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 15 20:54:28 PDT 2022
ivafanas created this revision.
ivafanas added reviewers: qcolombet, kparzysz, MatzeB.
Herald added subscribers: tpr, hiraditya.
Herald added a project: All.
ivafanas requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Instructions might use definition register as its "undef" operand. It happens on architectures with predicated execiton:
%0:subreg = instruction op_1, ..., op_N, undef %0:subreg, op_N+2, ...
RegisterCoalescer should take into account all remat instruction operands during destination subregister fixup.
; remat result before fix:
%1 = instruction op_1, ..., op_N, undef %1:subreg, op_N+2, ...
; remat result after fix (correct):
%1 = instruction op_1, ..., op_N, undef %1, op_N+2, ...
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125657
Files:
llvm/lib/CodeGen/RegisterCoalescer.cpp
Index: llvm/lib/CodeGen/RegisterCoalescer.cpp
===================================================================
--- llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -1379,8 +1379,19 @@
TRI->getCommonSubClass(DefRC, DstRC);
if (CommonRC != nullptr) {
NewRC = CommonRC;
+
+ // Instruction might contain "undef %0:subreg" as use operand:
+ // %0:subreg = insrt op_1, ..., op_N, undef %0:subreg, op_N+2, ...
+ //
+ // Need to check all operands.
+ for (MachineOperand &MO : NewMI.operands()) {
+ if (MO.isReg() && MO.getReg() == DstReg &&
+ MO.getSubReg() == DstIdx) {
+ MO.setSubReg(0);
+ }
+ }
+
DstIdx = 0;
- DefMO.setSubReg(0);
DefMO.setIsUndef(false); // Only subregs can have def+undef.
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125657.429601.patch
Type: text/x-patch
Size: 881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220516/75211eac/attachment.bin>
More information about the llvm-commits
mailing list