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

            Bug ID: 78125
           Summary: Shifted const forming is had
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64*-*-*

Take:
#define CONST1 0x1234567812345678ull
#define CONST2 (CONST1<<1)
#define CONST3 (CONST2<<1)
#define CONST4 (CONST3<<1)
#define CONST5 (CONST4<<1)
#define CONST6 (CONST5<<1)
#define CONST7 (CONST6<<1)
#define CONST8 (CONST7<<1)

void foo(unsigned long *a, unsigned long *b, unsigned long *c,
         unsigned long *d, unsigned long *e, unsigned long *f,
         unsigned long *g, unsigned long *h)
{
        *a = CONST1;
        *b = CONST2;
        *c = CONST3;
        *d = CONST4;
        *e = CONST5;
        *f = CONST6;
        *g = CONST7;
        *h = CONST8;
}

---- CUT ----

Right now the generated code generates the constant for each of the above
constants but we should be able to optimize it using left shifts.  We are able
to handle plus but not shifted values (or rotated values, see PR63281).

Reply via email to