https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70308
Uroš Bizjak <ubizjak at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ebotcazou at gcc dot gnu.org, | |law at redhat dot com Component|target |middle-end --- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> --- The problem is actually in expr.c expanders, in this particular case set_storage_via_setmem expander. These expanders loop from narrowest mode to wider modes: for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) { enum insn_code code = direct_optab_handler (setmem_optab, mode); if (code != CODE_FOR_nothing ... x86_64 declares "movmem<mode>" expander that defines both, movmemdi *AND* movmemsi on x86_64. Since the above loop expands narrowest mode first, it first checks movmemsi (which x86_64 uses as well). Basing on the promise that wider-mode expanders are inherently faster, this is middle-end deficiency. Middle-end should reverse mode scanning loop to check wider modes first. Adding some CCs.