summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineLoopUtils.cpp
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2022-06-19 18:55:19 +0100
committerDavid Green <david.green@arm.com>2022-06-19 18:55:19 +0100
commite995e34469be69d867dcf67935faead59feee9b1 (patch)
tree29c376b7d248d4a647a350cbc837979ba7b5782f /llvm/lib/CodeGen/MachineLoopUtils.cpp
parent30c675878c21be9973faabddc38ebf1b4c603b7d (diff)
[MachinePipeliner] Handle failing constrainRegClass
The included test hits a verifier problems as one of the instructions: ``` %113:tgpreven, %114:tgprodd = MVE_VMLSLDAVas16 %12:tgpreven(tied-def 0), %11:tgprodd(tied-def 1), %7:mqpr, %8:mqpr, 0, $noreg, $noreg ``` Has two inputs that come from different PHIs with the same base reg, but conflicting regclasses: ``` %11:tgprodd = PHI %103:gpr, %bb.1, %16:gpr, %bb.2 %12:tgpreven = PHI %103:gpr, %bb.1, %17:gpr, %bb.2 ``` The MachinePipeliner would attempt to use %103 for both the %11 and %12 operands in the prolog, constraining the register class to the common subset of both. Unfortunately there are no registers that are both odd and even, so the second constrainRegClass fails. Fix this situation by inserting a COPY for the second if the call to constrainRegClass fails. The register allocation can then fold that extra copy away. The register allocation of Q regs changed with this test, but the R regs were the same and no new instructions are needed in the final assembly. Differential Revision: https://reviews.llvm.org/D127971
Diffstat (limited to 'llvm/lib/CodeGen/MachineLoopUtils.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineLoopUtils.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineLoopUtils.cpp b/llvm/lib/CodeGen/MachineLoopUtils.cpp
index 6d0f90f8af1e..bf7d26dda985 100644
--- a/llvm/lib/CodeGen/MachineLoopUtils.cpp
+++ b/llvm/lib/CodeGen/MachineLoopUtils.cpp
@@ -63,7 +63,10 @@ MachineBasicBlock *llvm::PeelSingleBlockLoop(LoopPeelDirection Direction,
if (Use.getParent()->getParent() != Loop)
Uses.push_back(&Use);
for (auto *Use : Uses) {
- MRI.constrainRegClass(R, MRI.getRegClass(Use->getReg()));
+ const TargetRegisterClass *ConstrainRegClass =
+ MRI.constrainRegClass(R, MRI.getRegClass(Use->getReg()));
+ assert(ConstrainRegClass &&
+ "Expected a valid constrained register class!");
Use->setReg(R);
}
}