]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: Disable string insn from non-default AS for Pmode != word_mode [PR111657]
authorUros Bizjak <ubizjak@gmail.com>
Tue, 29 Apr 2025 16:08:05 +0000 (18:08 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Tue, 29 Apr 2025 16:15:03 +0000 (18:15 +0200)
commit69669180d29cc420b1b1ac86530a4f9573748d81
treed39f89589fc3a0b4b5889d64c2ab04656fb6897c
parent7c2e60f67a02d17d8c2f67ba438fdb50d51bc9f4
i386: Disable string insn from non-default AS for Pmode != word_mode [PR111657]

0x67 prefix is applied before segment register. That is in

rep movsq %gs:(%esi), (%edi)

the address is %gs + %esi. In case Pmode != word_mode (x32 with a default
-maddress-mode=short) instructions should not allow segment override prefixes.

Also, remove explicit addr32 prefix from asm templates because address
mode can be determined from explicit instruction operands. Also note that
Pmode != word_mode only with TARGET_64BIT, so the check in ix86_print_operand
is not needed.

PR target/111657

gcc/ChangeLog:

* config/i386/i386-expand.cc (alg_usable_p): For Pmode != word_mode
reject rep_prefix_{1,4,8}_byte algorithms with src_as in the
non-default address space.
* config/i386/i386-protos.h (ix86_check_movs): New prototype.
* config/i386/i386.cc (ix86_check_movs): New function.
(ix86_print_operand) [case '^']: Remove excess check for TARGET_64BIT.
* config/i386/i386.md (strmov): For Pmode != word_mode expand with
gen_strmov_single only when operands[3] (source) is in the default
address space.
(*strmovdi_rex_1) Use ix86_check_movs.  Remove %^ from asm template.
(*strmovsi_1): Ditto.
(*strmovhi_1): DItto.
(*strmovqi_1): Ditto.
(*rep_movdi_rex64): Ditto.
(*rep_movsi): Ditto.
(*rep_movqi): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr111657-1.c: Check that segment override is not
generated for "rep movsq" for x32 target.
gcc/config/i386/i386-expand.cc
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.cc
gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/pr111657-1.c