This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/70308] memset generates rep stosl instead of rep stosq
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 Mar 2016 10:47:37 +0000
- Subject: [Bug middle-end/70308] memset generates rep stosl instead of rep stosq
- Auto-submitted: auto-generated
- References: <bug-70308-4 at http dot gcc dot gnu dot org/bugzilla/>
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.