https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122716
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tamar Christina <[email protected]>: https://gcc.gnu.org/g:a2784b838ac3ab0c763c0fbb90b7e5f5b93fe196 commit r17-6833-ga2784b838ac3ab0c763c0fbb90b7e5f5b93fe196 Author: Tamar Christina <[email protected]> Date: Mon Nov 30 08:22:20 2026 +0000 aarch64: use multi-character print operands for endian SIMD lane masks [PR122716] This is the same cleanup as the previous patch, but for the cases where the operand is a lane mask of the form 1 << lane rather than a lane number. Some Advanced SIMD insert patterns receive an integer mask in which the single set bit encodes the lane. For example, lane 3 is represented as 1 << 3. The assembler still wants the lane number in architectural lane order, so the old templates had to compute: ENDIAN_LANE_N (nunits, exact_log2 (mask)) in C before returning the final instruction text. This patch adds an internal print operand for that: %[ENDIAN_LANE_MASK:0,2] Operand 0 supplies the register mode and operand 2 supplies the mask. The print hook gets the lane count from the register mode, checks that the mask is a valid single-bit constant, turns it back into a lane number, applies the endian adjustment, and prints the result. The machine description can then express the instruction directly, for example: ins\t%0.<Vetype>[%[ENDIAN_LANE_MASK:0,2]], %3.<Vetype>[%[ENDIAN_LANE:3,4]] Keeping this separate from ENDIAN_LANE makes the expected operand form clear: one modifier takes a lane number, the other takes a mask of the form 1 << lane. Both use the same code to get the lane count and apply the endian adjustment. The tests also check lane copies between vectors of different widths in both little- and big-endian output. gcc/ChangeLog: PR target/122716 * config/aarch64/aarch64-print-operands.def (endian_lane_mask, ENDIAN_LANE_MASK): New definitions. (ENDIAN_LANE1, ENDIAN_LANE2, ENDIAN_LANE4, ENDIAN_LANE8, ENDIAN_LANE16): Reformat. * config/aarch64/aarch64.cc (aarch64_print_operand): Handle ENDIAN_LANE_MASK in the lane printer. Reject negative lane numbers and invalid masks. * config/aarch64/aarch64-simd.md (@aarch64_simd_vec_set<mode>): Use ENDIAN_LANE_MASK and compact syntax for the Adv. SIMD pattern. (@aarch64_simd_vec_copy_lane<mode>): Use ENDIAN_LANE_MASK and ENDIAN_LANE. (@aarch64_simd_vec_copy_lane_<vswap_width_name><mode>): Likewise. * config/aarch64/iterators.md (vswap_width_nunits): Remove. (dot_lane_count): Reindent. (FCMLA_maybe_lane): Move its comment back above the definition. gcc/testsuite/ChangeLog: PR target/122716 * gcc.target/aarch64/named-operand-lanes-be.c: Check lane set, load, copy and fused multiply-subtract instructions. * gcc.target/aarch64/named-operand-lanes-le.c: Likewise. * gcc.target/aarch64/named-operand-lanes.h (copy_64_to_128): New function. (copy_128_to_64): Likewise. (set_lane): Likewise. (load_lane): Likewise. (fms_64_to_128): Likewise. (fms_scalar): Likewise.
