https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127459
liu zhenyu <lzy20000419 at outlook dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lzy20000419 at outlook dot com
--- Comment #9 from liu zhenyu <lzy20000419 at outlook dot com> ---
The r17-5731 fix for avx_vec_concat does not cover vec_set_lo/hi. On trunk
17.0.0 20261126, gcc.target/i386/pr127459-1b.c now correctly emits vinserti128,
but these patterns still emit 256-bit vinsert*64x2 with -O2 -mavx512dq
-mno-avx512vl:
#include <immintrin.h>
__m256i hi_q (__m256i a, __m128i b) { return _mm256_inserti128_si256 (a, b,
1); }
__m256i lo_q (__m256i a, __m128i b) { return _mm256_inserti128_si256 (a, b,
0); }
__m256d hi_d (__m256d a, __m128d b) { return _mm256_insertf128_pd (a, b,
1); }
$ gcc -O2 -mavx512dq -mno-avx512vl -S t.c -o - | grep vinsert
vinserti64x2 $0x1, %xmm1, %ymm0, %ymm0
vinserti64x2 $0x0, %xmm1, %ymm0, %ymm0
vinsertf64x2 $0x1, %xmm1, %ymm0, %ymm0
Those 256-bit forms need AVX512VL as well as AVX512DQ. An assembler limited to
the enabled ISAs rejects them (`as --64
-march=generic64+avx2+avx512f+avx512dq`: "operand size mismatch for
`vinserti64x2'"). The same flags with no DQ, and the 32-bit-element forms
(_mm256_insertf128_ps), still give vinserti128/vinsertf128.
The output templates in sse.md (`vec_set_lo_<mode><mask_name>` and
`vec_set_hi_<mode><mask_name>` for VI8F_256) choose vinsert*64x2 whenever
TARGET_AVX512DQ, including the `isa "noavx512vl,avx512vl"` alternative 0. A
test next to pr127459-1b.c would be useful.
Disclaimer: This test case was found with LLM-assisted targeted testing, and
the comment was written with LLM assistance.