Constants are crucial for code size in the ARM Thumb-1 instruction set.
The 16 bit instruction size often does not offer enough space for immediate arguments.
This means that additional instructions are frequently used to load constants into registers.
Since constants are hoisted, this can lead to significant register spillage if they are used multiple times in a single function.
This can be avoided by rematerialization, i.e. recomputing a constant instead of reloading it from the stack.
This patch fixes the rematerialization of literal pool loads in the ARM Thumb instruction set.
Details
Diff Detail
Event Timeline
Hi Philip,
Could you re-upload the patch with some added context please? Something like -U100 would be great.
cheers,
sam
Hi Philip,
Are these tests standalone for just this patch, or in conjunction with D33935? If it's difficult to test separately (I'm assuming so), I think you should combine these two patches so they can be committed and tested together.
cheers,
sam
Hi Sam,
The patches are related in their purpose but completely separate in the functionality that they actually touch.
Both patches therefore now have a different test, there is no need to merge them.
Best,
Philip
test/CodeGen/Thumb/litpoolremat.ll | ||
---|---|---|
24 ↗ | (On Diff #106389) | That could be done as well, but I think this more specifically checks the exact functionality of the patch, i.e. to avoid spilling of literal pools loads (and only of them). |
test/CodeGen/Thumb/select.ll | ||
77 ↗ | (On Diff #106389) | Essentially there are two things going on here:
|
test/CodeGen/Thumb/litpoolremat.ll | ||
---|---|---|
24 ↗ | (On Diff #106389) | Ok, I asked a bad question, I mean why aren't we testing that the immediate is not spilled once its loaded? It would also be good to check what data is at LCPIO_0. |
test/CodeGen/Thumb/litpoolremat.ll | ||
---|---|---|
24 ↗ | (On Diff #106389) | You are definitely right that it would be nice to verify that LCPIO_0 is indeed where the constant 1764 is stored. |
test/CodeGen/Thumb/litpoolremat.ll | ||
---|---|---|
24 ↗ | (On Diff #106389) | I added the check for LCPIO_0. |
test/CodeGen/Thumb/litpoolremat.ll | ||
---|---|---|
24 ↗ | (On Diff #106389) | I didn't mean you should do the spill check instead of what you have done, I just meant as a supplement. It would be nice to have the extra explicit check that there's no 'str r0, [sp]' after the initial load. for the literal pool check, you could perform the check after the code checks with something like: |
test/CodeGen/Thumb/litpoolremat.ll | ||
---|---|---|
24 ↗ | (On Diff #106389) | Agreed, I added both. |