https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111657
--- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Uros Bizjak <u...@gcc.gnu.org>: https://gcc.gnu.org/g:aa29654b1128a572c97fcaba94095f493662a0db commit r16-276-gaa29654b1128a572c97fcaba94095f493662a0db Author: Uros Bizjak <ubiz...@gmail.com> Date: Tue Apr 29 10:25:45 2025 +0200 i386: Allow string instructions from non-default address space [PR111657] MOVS instructions allow segment override of their source operand, e.g.: rep movsq %gs:(%rsi), (%rdi) where %rsi is the address of the source location (with %gs segment override) and %rdi is the address of the destination location. The testcase improves from (-O2 -mno-sse -mtune=generic): xorl %eax, %eax .L2: movl %eax, %edx addl $8, %eax movq %gs:m(%rdx), %rcx movq %rcx, (%rdi,%rdx) cmpl $240, %eax jb .L2 ret to: movl $m, %esi movl $30, %ecx rep movsq %gs:(%rsi), (%rdi) ret PR target/111657 gcc/ChangeLog: * config/i386/i386-expand.cc (alg_usable_p): Remove have_as bool argument and add dst_as and src_as address space arguments. Reject libcall algorithm with dst_as and src_as in the non-default address spaces. Reject rep_prefix_{1,4,8}_byte algorithms with dst_as in the non-default address space. (decide_alg): Remove have_as bool argument and add dst_as and src_as address space arguments. Update calls to alg_usable_p. (ix86_expand_set_or_cpymem): Update call to decide_alg. * config/i386/i386.md (strmov): Do not fail if operand[3] (source) is in the non-default address space. Expand with gen_strmov_singleop only when operand[1] (destination) is in the default address space. (*strmovdi_rex_1): Determine memory operands from insn pattern. Allow only when destination is in the default address space. Rewrite asm template to use explicit operands. (*strmovsi_1): Ditto. (*strmovhi_1): DItto. (*strmovqi_1): Ditto. (*rep_movdi_rex64): Ditto. (*rep_movsi): Ditto. (*rep_movqi): Ditto. (*strsetdi_rex_1): Determine memory operands from insn pattern. Allow only when destination is in the default address space. (*strsetsi_1): Ditto. (*strsethi_1): Ditto. (*strsetqi_1): Ditto. (*rep_stosdi_rex64): Ditto. (*rep_stossi): Ditto. (*rep_stosqi): Ditto. gcc/testsuite/ChangeLog: * gcc.target/i386/pr111657-1.c: New test.