-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[SystemZ] Register clobber in L128 expansion #91437
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
It seems like L128 doesn't get produced for "normal" use of i128, but only for spills from the register allocator(?), so it's probably easier to consider this directly in MIR. The following test case is for
Results ins:
|
A possible fix would be to swap the two instructions in this case. Though one could still have a situation like
where neither order would be correct. But I assume that can't happen in practice, at least as L128 is used currently. |
Looks to me like you meant to write L128 with $r15d (SP) and not $r5d..? I agree that it seems correct to change the order of the loads, and also add an assert either that the base register is the SP, or that it is not a subreg of the destination quadword reg. |
I think @nikic did mean $r5d - if base and index happen to be the two registers that make up the GR128 (in this case $r4q made up of $r4d and $r5d), there is no way to split the load into component loads without a temporary register. However, I believe there's no need to support this case, as this instruction is only ever used to access spill slots, so at least of of base and index (typically base, but we probably don't have to assume that) will be either the stack or the frame pointer, which cannot be part of any GR128 that is in use. I think we should just check whether one of base or index overlap the output and adjust the sequence to accommodate. If both base or index overlap, this should just fail an assertion. |
Ah, I see the point now. Patch proposed (see above). |
When expanding an L128 (which is used to reload i128) it is possible that the quadword destination register clobbers an address register. This patch adds an assertion against the case where both of the expanded parts clobber the address, and in the case where one of the expanded parts do so puts it last. Fixes #91437
/cherry-pick d6ee7e8 |
When expanding an L128 (which is used to reload i128) it is possible that the quadword destination register clobbers an address register. This patch adds an assertion against the case where both of the expanded parts clobber the address, and in the case where one of the expanded parts do so puts it last. Fixes llvm#91437 (cherry picked from commit d6ee7e8)
/pull-request #92221 |
When expanding an L128 (which is used to reload i128) it is possible that the quadword destination register clobbers an address register. This patch adds an assertion against the case where both of the expanded parts clobber the address, and in the case where one of the expanded parts do so puts it last. Fixes llvm#91437 (cherry picked from commit d6ee7e8)
Running https://gist.github.com/nikic/974087a15f48f4495f25361bae3015d2 through
llc -mtriple=s390x--
gives something like this:Note that
%r4
is used in the load offset calculation, but also one of the result registers.Originally, this is a L128:
That gets expanded into two LG, resulting in the register clobber:
The text was updated successfully, but these errors were encountered: