Skip to content

Commit d0482d1

Browse files
JoshHuttonCodegithub-actions[bot]
authored andcommitted
Automerge: [AMDGPU] Avoid constraining RC based on folded into operand (NFC) (#160743)
The RC of the folded operand does not need to be constrained based on the RC of the current operand we are folding into. The purpose of this PR is to facilitate this PR: llvm/llvm-project#151033
2 parents 70dafe5 + de59bc4 commit d0482d1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/lib/Target/AMDGPU/SIFoldOperands.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,15 @@ bool SIFoldOperandsImpl::updateOperand(FoldCandidate &Fold) const {
712712
TII->getRegClass(MI->getDesc(), Fold.UseOpNo, TRI)) {
713713
const TargetRegisterClass *NewRC =
714714
TRI->getRegClassForReg(*MRI, New->getReg());
715-
const TargetRegisterClass *ConstrainRC =
716-
TRI->findCommonRegClass(OpRC, Old.getSubReg(), NewRC, New->getSubReg());
717-
if (!ConstrainRC)
718-
return false;
715+
716+
const TargetRegisterClass *ConstrainRC = OpRC;
717+
if (New->getSubReg()) {
718+
ConstrainRC =
719+
TRI->getMatchingSuperRegClass(NewRC, OpRC, New->getSubReg());
720+
721+
if (!ConstrainRC)
722+
return false;
723+
}
719724

720725
if (!MRI->constrainRegClass(New->getReg(), ConstrainRC)) {
721726
LLVM_DEBUG(dbgs() << "Cannot constrain " << printReg(New->getReg(), TRI)

0 commit comments

Comments
 (0)