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

Better usage of load/store multiple #4

Open
wants to merge 5 commits into
base: nanomips-llvm16
Choose a base branch
from

Conversation

milica-lazarevic
Copy link
Collaborator

@milica-lazarevic milica-lazarevic commented Mar 15, 2023

LoadStoreMultiple optimization has been moved to the standalone pass. Compared to the previous implementation, we regocnize sequences not sorted by the reg:offset pairs as optimizable. Please take a look into the example below:

Now, a sequence like the following is optimizable:

lw a0, 8(a4)
lw a2, 16(a4) => lwm a0, 8(a4), 3
lw a1, 12(a4)

Also, there is support for optimizing the following sequences:

lw a0, 8(a4)
lw a1, 12(a4) => lwm a0, 8(a4), 4
lw a3, 20(a4)

lw a0, 8(a4)
lw a1, 12(a4) => lwm a0, 8(a4), 3 move a3, a2
lw a3, 16(a4)

llvm/lib/Target/Mips/NanoMipsLoadStoreMultiple.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/Mips/NanoMipsLoadStoreMultiple.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/Mips/NanoMipsLoadStoreMultiple.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/Mips/NanoMipsLoadStoreMultiple.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/Mips/NanoMipsLoadStoreMultiple.cpp Outdated Show resolved Hide resolved
@djtodoro
Copy link
Collaborator

djtodoro commented Jun 4, 2024

@milica-lazarevic what is the status of this? Can we port it to LLVM 16?

@milica-lazarevic milica-lazarevic force-pushed the better-usage-of-load/store-multiple branch from ea54f31 to 5ce4b7e Compare September 13, 2024 13:23
@milica-lazarevic milica-lazarevic changed the base branch from nanomips-llvm13 to nanomips-llvm16 September 13, 2024 13:24
@milica-lazarevic
Copy link
Collaborator Author

@milica-lazarevic what is the status of this? Can we port it to LLVM 16?

This PR has been ported to LLVM 16.

@milica-lazarevic milica-lazarevic force-pushed the better-usage-of-load/store-multiple branch from 5ce4b7e to 7c2e46b Compare September 16, 2024 11:21
LoadStoreMultiple optimization has been moved to the standalone pass so
it can be expanded. Potentially, its position in a pipeline could be
changed.
Additional support is added to recognize more sequences. Before,
a sequence like this wasn't accepted:

lw a1, 4(a0)
lw a3, 12(a0)
lw a2, 8(a0)

Now, when we're sorting instructions by the reg:offset pair internally,
the above is accepted.
Beside regular instruction sequence, we're also looking for an
instruction sequence that's "missing" one(or more) instruction to be
complete and interchangeable with lwm/swm instruction. The sequence is
optimizable if the Rt register in missing instruction is available.
We're handling the situation where the instruction sequence is regular,
except for one instruction having a "wrong" Rt register number. A
sequence like that is optimizable if the register with the expected
register number is available. In that case, we're emitting one
additional move instruction after lwm/swm.
@milica-lazarevic milica-lazarevic force-pushed the better-usage-of-load/store-multiple branch from 7c2e46b to 5ea10a5 Compare September 16, 2024 11:25
@djtodoro
Copy link
Collaborator

Since we have confirmed a 0.13% improvement in code size, I recommend we proceed with merging this change as is.

@milica-lazarevic
Copy link
Collaborator Author

Last commit ("NanoMIPS: NMLoadStoreMultiple add reg gap support") has been temporarily reverted due to a bug.

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.

3 participants