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

aarch64: __builtin_shufflevector with a zero vector CST as the second argument and doing a "ext" like should produce ushr/shl #81393

Open
pinskia opened this issue Feb 11, 2024 · 3 comments

Comments

@pinskia
Copy link

pinskia commented Feb 11, 2024

Take:

#define vect64 __attribute__((vector_size(8)))

void f(vect64  unsigned short *a)
{
  *a = __builtin_shufflevector(*a,(vect64 unsigned short){0}, 2,3, 4,5);
}

This should just produce (for little-endian; big-endian should be shl instead):

        ldr     d31, [x0]
        ushr d31, d31, 32
        str     d31, [x0]

Right now, LLVM produces mov/ext to do this shuffle.

@pinskia
Copy link
Author

pinskia commented Feb 11, 2024

Note LLVM is able to handle this for x86_64. GCC is just the opposite; handling it for aarch64 and not for x86_64. Filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113871 for the GCC not handling it on x86_64.

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 11, 2024

@llvm/issue-subscribers-backend-aarch64

Author: Andrew Pinski (pinskia)

Take: ``` #define vect64 __attribute__((vector_size(8)))

void f(vect64 unsigned short *a)
{
*a = __builtin_shufflevector(*a,(vect64 unsigned short){0}, 2,3, 4,5);
}

This should just produce (for little-endian; big-endian should be shl instead):
    ldr     d31, [x0]
    ushr d31, d31, 32
    str     d31, [x0]
Right now, LLVM produces mov/ext to do this shuffle.

</details>

@pinskia
Copy link
Author

pinskia commented Feb 11, 2024

Note the first operand as 0 can use shl/ushr too.
Like:

#define vect64 __attribute__((vector_size(8)))

void f(vect64  unsigned short *a)
{
  *a = __builtin_shufflevector((vect64 unsigned short){0},*a, 3,4,5,6);
}

GCC does not catch this one though, I filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113872 for that.

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

No branches or pull requests

4 participants