From: | amker <can.finner@gmail.com> |
Newsgroups: | comp.compilers |
Date: | Tue, 1 Nov 2011 19:01:21 -0700 (PDT) |
Organization: | Compilers Central |
References: | 11-10-019 11-11-002 |
Keywords: | optimize |
Posted-Date: | 01 Nov 2011 22:26:39 EDT |
On Nov 1, 1:08 am, Kaz Kylheku <k...@kylheku.com> wrote:
> On 2011-10-31, Amker.Cheng <amker.ch...@gmail.com> wrote:
>
> > I found following intermediate codes are generated in gcc
>
> > rx <- 0
> > ...
> > use rx
> > ...
> > ry <- 0
> > use ry
> > ...
>
> > It's normally a result of const propagation.
> > After register allocation, It is likely rx/ry get allocated into
> > different hard registers.
> > Thus in final codes, there would be a redundant "move 0" instruction.
>
> Surely you mean, if they get allocated into the SAME register, there
> will be a redundant initialization?
Something like that. In register allocation, if there is no register
pressure issue, the program should be converted into
rx <- 0
...
use rx
...
rx <- 0 <----which is redundant and can be removed
use rx
> > The story even stands for Os compiling, so the question is:
> > Is there any optimization technique dedicates to this kind of case?
>
> It's a variant of ``common subexpression elimination''. This should
> be done early on. You have two different instances of 0 in the code,
> which should be recognized as a common subexpression, sharing the same
> intermediate code, and virtual registers.
Yes, I just found gcc's cse pass can handle such cases in extended
basic block, but not globally. Another question is, if we do it
before register allocation, the live range of rx would be extended and
might cause spill in register allocation.
Thanks
Return to the
comp.compilers page.
Search the
comp.compilers archives again.