This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/70308] memset generates rep stosl instead of rep stosq


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]