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

Vectorize [Ifloatarithmem] #3452

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gretay-js
Copy link
Contributor

On top of #3451.

There are two ways to vectorize Ifloatarithmem, for example for add` operation, we can either

  • two vector instructions: vector load followed by vector add with register arguments (effectively reverting the choice made during instruction selection).
  • emit one vector add instruction with a memory argument, but only when the memory is known to be 128-bit aligned.

This PR supports both options, although the more efficient one instruction cannot currently be emitted because we don't have the alignment guarantees. This can be enabled in the future if we propagate sufficient informaton about bigarrays for example, but may need runtime changes to ensure alignment.

To emit SIMD instructions with memory arguments, this PR adds a bunch of machinery to SIMD selection and handling to keep track of the addressing mode. In particular, it adds ISimd_mem to specific operations. The rest is trivial propagation of the new variant to all the right places. This is in a separate commit, which I am happy to split out into a separate PR if the design choices don't seem obvious. The new instructions are lightly tested manually (except for binary emitter), but are never emitted even when the vectorizer is enabled.

Currently it's always 8 but having this argument will help us
consider alignment for new vector sequences.
When the memory alignment is known to be 128-bit (currently, never) emits
[addpd], otherwise emits a vector load followed by an arithmetic
instruction.
@gretay-js gretay-js added simd SIMD support vectorizer labels Jan 9, 2025
@gretay-js gretay-js requested a review from xclerc January 9, 2025 12:41
Copy link

github-actions bot commented Jan 9, 2025

Selection Change Check

This PR modifies the original selection pass (targeting Mach).
Please check whether the changes should also be applied to the
CFG variant of the pass.

@gretay-js gretay-js mentioned this pull request Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
simd SIMD support vectorizer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant