Skip to content

[LLVM][AArch64][SVE] Mark DUP immediate instructions with isAsCheapAsAMove. #133945

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

Merged
merged 1 commit into from
Apr 3, 2025

Conversation

paulwalker-arm
Copy link
Collaborator

@paulwalker-arm paulwalker-arm commented Apr 1, 2025

Doing this means we'll regenerate an immediate rather than copy the result of an existing one, reducing instruction dependency chains.

Looking at the output difference of #133929 I noticed this omission and so I figured it would be better to land this PR first so the effect of #133929 becomes more obvious. In general it seems like a common sense change which I think might be applicable to some other instructions (e.g. pfalse) but for now I've limited to regular vector splat immediate operations.

…AMove.

Doing this means we'll regenerate an immediate rather than copy the
result of an existing one, reducing instruction dependency chains.
Copy link
Member

@MacDue MacDue left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me 👍

@david-arm
Copy link
Contributor

This does seem like a sensible patch, but can it also have unwanted side-effects? For example, MachineLICM is often incredibly aggressive and likes to hoist invariants as far away from the original loop as it possibly can. When you throw intervening function calls in to the mix, could it lead to more fills and spills? I guess it depends upon the ABI and whether or not it's a level playing field, i.e. if SVE and NEON are treated equally then at least it's no different to marking NEON dups as cheap as a move.

@paulwalker-arm
Copy link
Collaborator Author

paulwalker-arm commented Apr 2, 2025

When you throw intervening function calls in to the mix, could it lead to more fills and spills?

The affected instructions are also marked with isReMaterializable so we should not need to spill them. Whilst this change might trigger more LICM I figure if that does trigger the need to spill, the end result will be to spill one of these rematerialisable instructions first and so the affect would be the same as if the COPY/DUP had not been hoisted in the first place?

Copy link
Contributor

@david-arm david-arm left a comment

Choose a reason for hiding this comment

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

LGTM!

@paulwalker-arm paulwalker-arm merged commit ee4e819 into llvm:main Apr 3, 2025
12 checks passed
@paulwalker-arm paulwalker-arm deleted the sve-cheap-as-mov branch April 3, 2025 10:42
qiaojbao pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Apr 29, 2025
Local branch origin/amd-gfx 543f39b Merged main:f99072bd8c6b into origin/amd-gfx:76d6615e816f
Remote branch main ee4e819 [LLVM][AArch64][SVE] Mark DUP immediate instructions with isAsCheapAsAMove. (llvm#133945)
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