This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Abt RTL expression - Optimization


On 26 Oct 2006 22:02:04 -0700, Ian Lance Taylor <iant@google.com> wrote:
"Rohit Arul Raj" <rohitarulraj@gmail.com> writes:

> This small bit of code worked fine with all optimization except Os.
>
> unsigned int n = 30;
> void x ()
> {
>  unsigned int h;
>  h = n <= 30;           // Line 1
>  if (h)
>    p = 1;
>  else
>    p = 0;
> }
>
> when we tried to debug the emitted RTL instruction for Os, it was
> found that RTL instruction for Line #1 (Compare and gtu) were not at
> all emitted. i.e. there is no reference with respect to "h or n". For
> the same optimization Os, if we declare the identifier "h" as global,
> it generates the instructions properly.

That small bit of code won't compile, since 'p' is undeclared.  If 'p'
is a global variable, then this certainly seems to be a bug.  But you
should be aware that -Os changes inlining behaviour, and different
inlining may cause different behaviour here depending on how 'p' is
used.

p is a global variable. But the problem is not with p, but with codegeneration for h, n.


> While checking the Dumps of RTL, the above mentioned code for "h, n" > was present in the file 20020611-1.c.25.cse2 but not in > 20020611-1.c.26.life1. > > 1. Is the file 20020611-1.c.25.cse2 input to life1 optimization pass?

It is a dump of what the intermediate representation looks like after
the cse2 pass.


In the RTL dump after cse2 pass, i do have the code for h, n. But in the RTL dump after life analysis, that part of code is missing. Is this output of cse2 pass used for life analysis?

> 2. What does .life1 Life analysis pass do ?

It does flow analysis: it records which pseudo-registers are live at
all parts of the program.  It also does a number of minor random
cleanups.


> 3. What are the probable causes for the elimination of RTL code's > (Compare & gtu) between the above mentioned passes?

The probable cause is that 'p' appears to be unused, and the
assignment to 'p' is dead.

since p is a global variable, it can be used in other functions. Any
other causes?

4. If i disable gcse optimization pass, (i.e. -Os -fno-gcse), the code
is generated properly for h , n and the program works fine (it failed
for -Os). How does gcse affect code generation at .life1 pass.


Regards, Rohit


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]