In order for my CSE const anchor patch to work I needed to drastically lower
the cost of immediate addition in the MIPS backend.  This was acceptable as a
proof of concept but not in general of course.

The problem is with "single-insn"/simple constants.  We would also like these
to use const anchors in the hope that the resulting expression would get
propagated into MEM expressions.  I was hoping that fwprop would do this
propagation for me.  However, since a single-insn constant load is cheaper
than an immediate addition (make sense), fwprop is free to propagate either
(1) into (2) or (2) into (3) here:

  (1) a <- C
      |
      +--> (2) b <- a + D
      |        |
      |        +--> (3) mem(b)
      |
      +--> (4) use(a)

Which one it does depends on which one it tries first.  Right now we go in
insn order so we'd do (1) to (2) preventing to do (2) to (3) later.

It seems to me that it would be preferable if fwprop tried propagating into
single uses first before trying to propagate into others.  This should improve
the chances of making more defs redundant.  With the example above, (2) would
be redundant after propagation.

Am I missing something?  If this sounds reasonable I can try to work out a
patch and see what happens.

Adam

Reply via email to