On 11/18/26 4:43 AM, [email protected] wrote:
From: Kyrylo Tkachov <[email protected]>

The VEC_CONCAT simplification added for PR target/48609 in b085ae4b49b4
rewrites

   (vec_concat:N (subreg:N/2 OP 0) (subreg:N/2 OP N/2))

into a lowpart of OP without checking that the target allows accessing
OP in the result mode.  On AArch64, V2x8QI (two D registers) and V16QI
(one Q register) have the same size but cannot be tied.  The vtbl2 and
vtbx2 expanders build the table with aarch64_combinev8qi from the two
halves of a V2x8QI tuple, so combine now produces

   (set (reg:V16QI table) (subreg:V16QI (reg:V2x8QI tuple) 0))

which reload can only satisfy through the stack:

   sub   sp, sp, #16
   stp   d0, d1, [sp]
   ldr   q31, [sp]
   tbl   v0.8b, {v31.16b}, v2.8b
   add   sp, sp, 16
   ret

Require targetm.modes_tieable_p for register bases, so the VEC_CONCAT is
kept and the code is:

   zip1  v0.2d, v0.2d, v1.2d
   tbl   v0.8b, {v0.16b}, v2.8b
   ret

The vtbl2 and vtbx2 tests in gcc.target/aarch64/neon expected the stack
sequence, so update them to the new code.  This also fixes the test_tbl2
and test_tbx2 failures in gcc.target/aarch64/simd/mf8_data_1.c.

Bootstrapped and tested on aarch64-none-linux-gnu.
Ok for trunk?
Thanks,
Kyrill

gcc/ChangeLog:

        * simplify-rtx.cc (simplify_context::simplify_binary_operation_1)
        <case VEC_CONCAT>: Check targetm.modes_tieable_p before merging
        subregs of the same register.

gcc/testsuite/ChangeLog:

        * gcc.target/aarch64/neon/vtbl.c: Expect zip1 instead of a stack
        round trip for vtbl2.
        * gcc.target/aarch64/neon/vtbx.c: Likewise for vtbx2.

Signed-off-by: Kyrylo Tkachov <[email protected]>
LGTM, Sashiko clean.  OK for the trunk.

jeff

Reply via email to