https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128913
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Kyrylo Tkachov <[email protected]>: https://gcc.gnu.org/g:f4c71f7ce94f96ade39dca65b39178943243cdb4 commit r17-7090-gf4c71f7ce94f96ade39dca65b39178943243cdb4 Author: Kyrylo Tkachov <[email protected]> Date: Tue Nov 24 02:59:58 2026 -0800 aarch64: Fix SVE constant predicate TRN1 synthesis [PR128913] aarch64_expand_sve_const_pred_trn splits a constant predicate into A and B and merges them with a TRN1 of size PERMUTE_SIZE. It reuses the pattern count of the input constant for A and B, and fills in the elements that the TRN1 discards with filler values. That is only valid if every pattern has a fixed value of (I & PERMUTE_SIZE), that is, if the pattern count is a multiple of 2 * PERMUTE_SIZE. For the VNx4BI constant {1, 0, 1, 1, 1, 1, 1, 1} at -msve-vector-bits=256 the VNx16BI builder has 4 patterns and PERMUTE_SIZE is 8. Encoded elements 8-11 were treated as discarded and given filler values, but the extrapolation of A to bytes 16-23 repeats that filler while the TRN1 reads those bytes. GCC generated: ptrue p15.s, vl8 ptrue p7.d, vl4 trn1 p7.d, p7.d, p15.d which loses lane 5. Encode A and B with at least 2 * PERMUTE_SIZE patterns. The constant for this case is then no longer synthesised with a TRN1 and is loaded from the constant pool: adrp x2, .LANCHOR0 add x2, x2, :lo12:.LANCHOR0 ldr p7, [x2] Bootstrapped and tested on aarch64-none-linux-gnu. gcc/ChangeLog: PR target/128913 * config/aarch64/aarch64.cc (aarch64_expand_sve_const_pred_trn): Encode A and B with at least 2 * PERMUTE_SIZE patterns. gcc/testsuite/ChangeLog: PR target/128913 * gcc.target/aarch64/sve/pr128913.c: New test. * gcc.target/aarch64/sve/pr128913_2.c: Likewise. Signed-off-by: Kyrylo Tkachov <[email protected]>
