Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIE2P] Fix Accumulator Register Bank assignment for G_STORE #264

Open
wants to merge 1 commit into
base: aie-public
Choose a base branch
from

Conversation

khallouh
Copy link
Collaborator

For G_STORE, we look at the bank of the register in the defining instruction but we assume that this will be at index zero, which has been the case for AIE2P's intrinsics defining accumulators but not true in general.

}
return -1;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, can you add a test ?

Copy link
Collaborator Author

@khallouh khallouh Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't add a test triggering this bug because there is no intrinsic that ouputs an accumulator at index zero. but we can't assume that VReg is always defined at index 0 of DefMI as we don't know what DefMI will be.
( See replaced line: auto *RB = getRegBank(DefMI->getOperand(0).getReg(), MRI, TRI) )

@@ -766,11 +777,13 @@ AIE2PRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
break;
MachineInstr *DefMI = MRI.getVRegDef(VReg);
LLT Type = MRI.getType(VReg);
auto *RB = getRegBank(DefMI->getOperand(0).getReg(), MRI, TRI);
auto DefRegBank = getRegBank(
DefMI->getOperand(getVRegIndexInInstr(*DefMI, VReg)).getReg(), MRI,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is DefMI->getOperand(getVRegIndexInInstr(*DefMI, VReg)).getReg() same as VReg?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DefMI->getOperand(getVRegIndexInInstr(*DefMI, VReg)).getReg() is an operand and VReg is a register. So they cannot be the same.

return i;
}
}
return -1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a std::optional? This -1 looks dangerous regarding alternative uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants