------- Comment #15 from jakub at gcc dot gnu dot org  2008-11-19 21:12 -------
The advantage of such a RTL pass (or just adding such optimization to another
RTL pass) would be that it would handle also say:
struct S
{
  char a;
  char b;
  char c;
  char d;
} u __attribute__((aligned));

void
f1 (void)
{
  u = (struct S) { 1, 2, 3, 4 };
}

void
f2 (void)
{
  u.a = 1;
  u.b = 2;
  u.c = 3;
  u.d = 4;
}

void
f3 (void)
{
  u.d = 4;
  u.b = 2;
  u.a = 1;
  u.c = 3;
}

where only f1 used to be optimized into a single store by 3.2/3.3.  The
question is, do we want to do this only if constants are stored into
neighbouring < wordsize MEMs?  Do we need to use cselib to canonicalize the
addresses (similarly how DSE does it), or could we just rely on
MEM_EXPR/MEM_OFFSET/MEM_SIZE?  If bitfields are involved, combiner often helps
with merging adjacent bitfield stores into a single store, so this pass would
be desirable after the combiner (and probably before register allocation).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22141

Reply via email to