Hi all,

This is V3 of a fix for PR117850.  V2 wasn't picked up or pinged by me as my
work changed quickly, so I've taken the opportunity here to fix it up a bit.
The major differences from V1 are based on the feedback given there.

There are two things that I'd like to note:

        * This fold is more general than that required to fix PR117850, in that
        it chooses the highpart builtin whenever all of the interesting 
arguments
        are the highparts of vector varialbles.  This case is already (mostly)
        handled by combine, so it might not be necessary to do this here.  The
        real improvement that this fold makes is where we have vector highparts
        and vector constants (cases that look like the PR).

        * This code does not handle VOPs, which, IIUC, would need to be done
        when folding builtins which satisfy aarch64_modifies_global_state_p or
        aarch64_reads_global_state_p.  An example of where this might be useful
        is for extending floating-point conversions.  But, as I say, I'm not
        sure if this is worth it given combine can usually do this (the only
        counter-example I've run into being vcvt_f32_bf16).

V1: 
https://inbox.sourceware.org/gcc-patches/20250217190739.1680451-2-spencer.ab...@arm.com/
PR117850: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117850

Bootstrapped & regtested on aarch64-linux-gnu.  OK for master?

Thanks,
Spencer

Spencer Abson (1):
  aarch64: Fold builtins with highpart args to highpart equivalent
    [PR117850]

 gcc/config/aarch64/aarch64-builtin-pairs.def  |  73 ++
 gcc/config/aarch64/aarch64-builtins.cc        | 183 +++++
 .../aarch64/simd/fold_to_highpart_1.c         | 717 ++++++++++++++++++
 .../aarch64/simd/fold_to_highpart_2.c         |  89 +++
 .../aarch64/simd/fold_to_highpart_3.c         |  83 ++
 .../aarch64/simd/fold_to_highpart_4.c         |  38 +
 .../aarch64/simd/fold_to_highpart_5.c         |  92 +++
 .../aarch64/simd/fold_to_highpart_6.c         |  37 +
 .../gcc.target/aarch64/simd/vabal_combine.c   |  72 --
 9 files changed, 1312 insertions(+), 72 deletions(-)
 create mode 100644 gcc/config/aarch64/aarch64-builtin-pairs.def
 create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/fold_to_highpart_1.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/fold_to_highpart_2.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/fold_to_highpart_3.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/fold_to_highpart_4.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/fold_to_highpart_5.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/simd/fold_to_highpart_6.c
 delete mode 100644 gcc/testsuite/gcc.target/aarch64/simd/vabal_combine.c

-- 
2.34.1

Reply via email to