-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Eliminate getVLENFactoredAmount and expose muladd [nfc] #87881
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,7 +195,16 @@ void RISCVRegisterInfo::adjustReg(MachineBasicBlock &MBB, | |
Register ScratchReg = DestReg; | ||
if (DestReg == SrcReg) | ||
ScratchReg = MRI.createVirtualRegister(&RISCV::GPRRegClass); | ||
TII->getVLENFactoredAmount(MF, MBB, II, DL, ScratchReg, ScalableValue, Flag); | ||
|
||
assert(ScalableValue > 0 && "There is no need to get VLEN scaled value."); | ||
assert(ScalableValue % 8 == 0 && | ||
"Reserve the stack by the multiple of one vector size."); | ||
assert(isInt<32>(ScalableValue / 8) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be isUInt<32>? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unchanged from the original code. It arguably should be changed, but I'd prefer to revisit the cornercases of extremely large offsets here in a separate change. (Remember, we're talking about more than 2^31 VLEN sized slots here, that's... unlikely.) |
||
"Expect the number of vector registers within 32-bits."); | ||
uint32_t NumOfVReg = ScalableValue / 8; | ||
BuildMI(MBB, II, DL, TII->get(RISCV::PseudoReadVLENB), ScratchReg) | ||
.setMIFlag(Flag); | ||
TII->mulImm(MF, MBB, II, DL, ScratchReg, NumOfVReg, Flag); | ||
BuildMI(MBB, II, DL, TII->get(ScalableAdjOpc), DestReg) | ||
.addReg(SrcReg).addReg(ScratchReg, RegState::Kill) | ||
.setMIFlag(Flag); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amount is a
int32_t
and will never become 0 if it starts negative.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking a look at this, the caller never passes in a negative number. The previous code used a uint32_t for the amount, so I'm going to switch over the extracted routine to match. Note that this shouldn't matter as the caller passes the absolute value in here, and the assert that isInt<32> on a positive number should imply that uint32_t and int32_t are equivalent in practice.