Re: How to eliminate redundant constant move instructions

Kaz Kylheku <kaz@kylheku.com>
Mon, 31 Oct 2011 17:08:54 +0000 (UTC)

          From comp.compilers

Related articles
How to eliminate redundant constant move instructions amker.cheng@gmail.com (Amker.Cheng) (2011-10-31)
Re: How to eliminate redundant constant move instructions kaz@kylheku.com (Kaz Kylheku) (2011-10-31)
Re: How to eliminate redundant constant move instructions gneuner2@comcast.net (George Neuner) (2011-11-01)
Re: How to eliminate redundant constant move instructions gah@ugcs.caltech.edu (glen herrmannsfeldt) (2011-11-01)
Re: How to eliminate redundant constant move instructions can.finner@gmail.com (amker) (2011-11-01)
Re: How to eliminate redundant constant move instructions can.finner@gmail.com (amker) (2011-11-01)
Re: How to eliminate redundant constant move instructions can.finner@gmail.com (amker) (2011-11-01)
Re: How to eliminate redundant constant move instructions amker.cheng@gmail.com (amker) (2011-11-01)
[11 later articles]
| List of all articles for this month |

From: Kaz Kylheku <kaz@kylheku.com>
Newsgroups: comp.compilers
Date: Mon, 31 Oct 2011 17:08:54 +0000 (UTC)
Organization: A noiseless patient Spider
References: 11-10-019
Keywords: optimize
Posted-Date: 01 Nov 2011 15:59:34 EDT

On 2011-10-31, Amker.Cheng <amker.cheng@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?


> 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.



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.