Skip to content

Conversation

@david-arm
Copy link
Contributor

We sometimes see sequences of vasm operations like this:

ldimml ..., %x
storel %x, [%sp - 0x80]
ldimml ..., %y
storel %y, [%sp - 0x7c]

The stores are actually contiguous in memory and if they were next to each other they would be paired up into a storepairl. This patch looks for such patterns and rewrites them as

ldimml ..., %x
ldimml ..., %y
storepairl %x, %y, [%sp - 0x80]

We sometimes see sequences of vasm operations like this:

ldimml ..., %x
storel %x, [%sp - 0x80]
ldimml ..., %y
storel %y, [%sp - 0x7c]

The stores are actually contiguous in memory and if they were
next to each other they would be paired up into a storepairl.
This patch looks for such patterns and rewrites them as

ldimml ..., %x
ldimml ..., %y
storepairl %x, %y, [%sp - 0x80]
@meta-cla meta-cla bot added the CLA Signed label Nov 20, 2025
@meta-codesync
Copy link

meta-codesync bot commented Nov 20, 2025

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D87553158. (Because this pull request was imported automatically, there will not be any future comments.)

// store x0, [sp - 0x7c]
// In this example we can't push the first store next to the second due to the
// reuse of x0.
if (!st1.s.isVirt()) return false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just realised there might be a subtle (and unlikely) bug here because a virtual register (Vreg) does not tell you anything about the class of the register, i.e. integer or floating point? So the first store in the pair could in fact be storing out a FP value, while the second store could be of an integer value. The lowering of storepair currently assumes both registers are GPs.

I think the solution here is to find the definition of register st1.s and make sure it's also come from a ldimml.

@facebook-github-bot
Copy link
Contributor

@david-arm has updated the pull request. You must reimport the pull request before landing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants