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

            Bug ID: 95792
           Summary: Failure to optimize assignment of struct members to
                    memset
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

#define F0(a) i##a, 
#define F1(a) F0(a##0) F0(a##1) F0(a##2) F0(a##3) F0(a##4) F0(a##5) F0(a##6)
F0(a##7)
#define F2(a) F1(a##0) F1(a##1) F1(a##2) F1(a##3) F1(a##4) F1(a##5) F1(a##6)
F1(a##7)
#define F3(a) F2(a##0) F2(a##1) F2(a##2) F2(a##3) F2(a##4) F2(a##5) F2(a##6)
F2(a##7)
#define F4(a) F3(a##0) F3(a##1) F3(a##2) F3(a##3) F3(a##4) F3(a##5) F3(a##6)
F3(a##7)

#define H0(a) s->i##a = 0;
#define H1(a) H0(a##0) H0(a##1) H0(a##2) H0(a##3) H0(a##4) H0(a##5) H0(a##6)
H0(a##7)
#define H2(a) H1(a##0) H1(a##1) H1(a##2) H1(a##3) H1(a##4) H1(a##5) H1(a##6)
H1(a##7)
#define H3(a) H2(a##0) H2(a##1) H2(a##2) H2(a##3) H2(a##4) H2(a##5) H2(a##6)
H2(a##7)
#define H4(a) H3(a##0) H3(a##1) H3(a##2) H3(a##3) H3(a##4) H3(a##5) H3(a##6)
H3(a##7)

struct foo {
        int
        F4(0)
        bar;
};

void f (struct foo *s)
{
        H4(0)
}

With -O3, GCC "optimizes" this by storing words containing 0 for the entire
struct. LLVM instead just calls memset, which looks more reasonable.

Reply via email to