aarch64: Fold builtins with highpart args to highpart equivalent [PR117850]
Add a fold at gimple_fold_builtin to prefer the highpart variant of a builtin
if at least one argument is a vector highpart and all others are VECTOR_CSTs
that we can extend to 128-bits.
For example, we prefer to duplicate f0 and use UMULL2 here over DUP+UMULL:
gcc/ChangeLog:
PR target/117850
* config/aarch64/aarch64-builtins.cc (LO_HI_PAIRINGS): New, group the
lo/hi pairs from aarch64-builtin-pairs.def.
(aarch64_get_highpart_builtin): New function.
(aarch64_v128_highpart_ref): New function, helper to look for vector
highparts.
(aarch64_build_vector_cst): New function, helper to build duplicated
VECTOR_CSTs.
(aarch64_fold_lo_call_to_hi): New function.
(aarch64_general_gimple_fold_builtin): Add cases for the lo builtins
in aarch64-builtin-pairs.def.
* config/aarch64/aarch64-builtin-pairs.def: New file, declare the
parirs of lowpart-operating and highpart-operating builtins.
gcc/testsuite/ChangeLog:
PR target/117850
* gcc.target/aarch64/simd/vabal_combine.c: Removed. This is
covered by fold_to_highpart_1.c
* gcc.target/aarch64/simd/fold_to_highpart_1.c: New test.
* gcc.target/aarch64/simd/fold_to_highpart_2.c: Likewise.
* gcc.target/aarch64/simd/fold_to_highpart_3.c: Likewise.
* gcc.target/aarch64/simd/fold_to_highpart_4.c: Likewise.
* gcc.target/aarch64/simd/fold_to_highpart_5.c: Likewise.
* gcc.target/aarch64/simd/fold_to_highpart_6.c: Likewise.