This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
subregs
- From: Kenneth Zadeck <Kenneth dot Zadeck at NaturalBridge dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 28 Apr 2004 13:14:52 -0400
- Subject: subregs
- References: <200404271942.i3RJgJmJ020143@desire.geoffk.org>
- Reply-to: Kenneth dot Zadeck at NaturalBridge dot com
This is a reply to jeff's mail about subreg's in
http://gcc.gnu.org/ml/gcc/2004-04/msg01278.html
what is desirable is depends on where you are during a compilation.
It is desirable to have the front end of the compiler generate each
load and store as a seperate sequence, i.e. not combine them. The
motivation here is the same one where gcc currently treats the fields
of small structures as separate variables: each of the small
operations more likely to be optimized by the commoning and code
motion algorithms than if they are left as aggragates.
> (sequence [
> (insn (set (reg X_1) (reg X_0)))
> (insn (set (subreg (reg X_1)) Y))
> ])
However, it is also quite desirable to combine the loads and stores
back into aggragates (the jeff extension) as a optimization to be
performed very late, (ideally after some preliminary scheduling)
because you really can do a much better job with the low level code
generation if you can glom together the masking and shifting
operations for several loads and stores. This can be done with a
simple hack to any full redundancy elimination algorithm.
> This SEQUENCE, considered as a whole, is in SSA form. It has an
> input, X_0, and an output, X_1. X_1 will be set only by this insn.
>
> As an extension, it's nice to recognize cases like
>
> (insn (clobber (reg X)))
> (insn (set (subreg (reg X) 0) Y))
> (insn (set (subreg (reg X) 1) Z))
>
> which together set all of X, and turn them into
>
> (sequence [
> (insn (clobber (reg X_1)))
> (insn (set (subreg (reg X_1) 0) Y))
> (insn (set (subreg (reg X_1) 1) Z))
> ])
>
> to eliminate the dependency on the previous value of X; and it's also
> nice to eliminate unnecessary copies when converting out of SSA form
> (I think this is just an extension of the usual unnecessary copy
> elimination).
>