On Wed, Jul 1, 2026 at 7:10 AM Roger Sayle <[email protected]> wrote: > > > This patch enhances the i386 backend's stv2 pass to consider the > pattern (zero_extend:DI (mem:SI ...)) to be a candidate for conversion. > Loading an SImode value into an SSE register clears the rest of the > vector, i.e. effectively (v4si){ mem, 0, 0, 0 }, which can be used > to conveniently implement zero-extension to DImode, when performing > V2DImode Scalar-To-Vector (STV) conversion. > > Consider the new test case: > > long long y,z; > unsigned int p; > > void foo() > { > long long t = p; > t ^= y; > z = t; > } > > With -m32 -O2 -msse2 this currently generates: > > foo: movl p, %eax > xorl %edx, %edx > movd %edx, %xmm1 > movd %eax, %xmm0 > punpckldq %xmm1, %xmm0 > movq y, %xmm1 > pxor %xmm1, %xmm0 > movq %xmm0, z > ret > > With this patch we now generate: > > foo: movq y, %xmm1 > movd p, %xmm0 > pxor %xmm1, %xmm0 > movq %xmm0, z > ret > > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check, both with and without --target_board=unix{-m32} > with no new failures. Ok for mainline? Ok.
> > > 2026-06-30 Roger Sayle <[email protected]> > > gcc/ChangeLog > * config/i386/i386-features.cc (compute_convert_gain) <ZERO_EXTEND>: > Provide costs for the new transformation. > (convert_insn): Implement *zero_extendsidi2 using the backend's > vec_setv2di_0_zero_extendsi_1 pattern (i.e. movq mem, %xmm). > (general_scalar_to_vector_candidate_p): Consider the pattern > (zero_extend:DI (mem:SI ...)) to be a candidate for DImode STV. > > gcc/testsuite/ChangeLog > * gcc.target/i386/sse2-stv-6.c: New test case. > > > Thanks in advance, > Roger > -- > -- BR, Hongtao
