[PATCH] D154920: [RISCV] Contrain register class before replaceRegWith in RISCVMergeBaseOffset.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 10 22:39:29 PDT 2023
craig.topper created this revision.
craig.topper added reviewers: asb, reames, frasercrmck, luismarques.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: llvm-commits, wangpc, eopXD, MaskRay.
Herald added a project: LLVM.
The register being replaced might have a more restrictive register
class due to requirements of the using instruction. We should
constrain the register class to preserve any restrictions.
This was found in our downstream on a custom instruction. I don't
have a test case for upstream currently.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D154920
Files:
llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
Index: llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
+++ llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
@@ -140,6 +140,8 @@
if (Hi.getOpcode() != RISCV::AUIPC)
Lo.getOperand(2).setOffset(Offset);
// Delete the tail instruction.
+ MRI->constrainRegClass(Lo.getOperand(0).getReg(),
+ MRI->getRegClass(Tail.getOperand(0).getReg()));
MRI->replaceRegWith(Tail.getOperand(0).getReg(), Lo.getOperand(0).getReg());
Tail.eraseFromParent();
LLVM_DEBUG(dbgs() << " Merged offset " << Offset << " into base.\n"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154920.538919.patch
Type: text/x-patch
Size: 665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230711/57ba2d66/attachment.bin>
More information about the llvm-commits
mailing list