Skip to content

[AArch64][SVE] Fold constant operands for svmul and svdiv #110424

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

Closed
k-arrows opened this issue Sep 29, 2024 · 2 comments
Closed

[AArch64][SVE] Fold constant operands for svmul and svdiv #110424

k-arrows opened this issue Sep 29, 2024 · 2 comments
Assignees
Labels
backend:AArch64 missed-optimization SVE ARM Scalable Vector Extensions

Comments

@k-arrows
Copy link

As with #110392, GCC has implemented this in recent patches. Consider the following example.
https://godbolt.org/z/M8Pe1G6Ge

#include <arm_sve.h>

svint64_t test1 (svbool_t pg)
{
  return svmul_x (pg, svdup_s64 (5), svdup_s64 (3));
}

svint64_t test2 (svbool_t pg)
{
  return svdiv_x (pg, svdup_s64 (5), svdup_s64 (3));
}

GCC:

test1(__SVBool_t):
        mov     z0.d, #15
        ret
test2(__SVBool_t):
        mov     z0.d, #1
        ret

Clang:

test1(__SVBool_t):
        mov     z0.d, #5
        mul     z0.d, z0.d, #3
        ret

test2(__SVBool_t):
        mov     z0.d, #3
        mov     z1.d, #5
        sdivr   z0.d, p0/m, z0.d, z1.d
        ret

I referred to the GCC patch below.
svmul
svdiv

@k-arrows k-arrows added backend:AArch64 SVE ARM Scalable Vector Extensions and removed new issue labels Sep 29, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 29, 2024

@llvm/issue-subscribers-backend-aarch64

Author: None (k-arrows)

As with https://github.com//issues/110392, GCC has implemented this in recent patches. Consider the following example. https://godbolt.org/z/M8Pe1G6Ge ```cpp #include <arm_sve.h>

svint64_t test1 (svbool_t pg)
{
return svmul_x (pg, svdup_s64 (5), svdup_s64 (3));
}

svint64_t test2 (svbool_t pg)
{
return svdiv_x (pg, svdup_s64 (5), svdup_s64 (3));
}


GCC:
```asm
test1(__SVBool_t):
        mov     z0.d, #<!-- -->15
        ret
test2(__SVBool_t):
        mov     z0.d, #<!-- -->1
        ret

Clang:

test1(__SVBool_t):
        mov     z0.d, #<!-- -->5
        mul     z0.d, z0.d, #<!-- -->3
        ret

test2(__SVBool_t):
        mov     z0.d, #<!-- -->3
        mov     z1.d, #<!-- -->5
        sdivr   z0.d, p0/m, z0.d, z1.d
        ret

I referred to the GCC patch below.
svmul
svdiv

@paulwalker-arm paulwalker-arm self-assigned this Dec 23, 2024
@paulwalker-arm
Copy link
Collaborator

#134116 introduced general simplification support for SVE intrinsics that have an IR instruction equivalent. The PR only covered mul but has since been extended to cover the majority of binops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AArch64 missed-optimization SVE ARM Scalable Vector Extensions
Projects
None yet
Development

No branches or pull requests

4 participants