https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86010

            Bug ID: 86010
           Summary: [7/8 Regression] redundant memset with smaller size
                    not eliminated
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

Both GCC 6 and Clang 3.5 and later emit equally efficient code for both
functions in the test case below.  Starting with GCC 7, the code emitted for
h()  is suboptimal.

$ cat b.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout b.c
void f (void*);

void g (void)
{
  char a[8];
  __builtin_memset (a, 0, 8);
  __builtin_memset (a, 0, 8);

  f (a);
}

void h (void)
{
  char a[8];
  __builtin_memset (a, 0, 8);
  __builtin_memset (a, 0, 7);

  f (a);
}


;; Function g (g, funcdef_no=0, decl_uid=1958, cgraph_uid=0, symbol_order=0)

g ()
{
  char a[8];

  <bb 2> [local count: 1073741825]:
  __builtin_memset (&a, 0, 8);
  f (&a);
  a ={v} {CLOBBER};
  return;

}



;; Function h (h, funcdef_no=1, decl_uid=1962, cgraph_uid=1, symbol_order=1)

h ()
{
  char a[8];

  <bb 2> [local count: 1073741825]:
  __builtin_memset (&MEM[(void *)&a + 6B], 0, 2);
  __builtin_memset (&a, 0, 7);
  f (&a);
  a ={v} {CLOBBER};
  return;

}

Reply via email to