Re: bug or feature? CSE optimizes away global, fixed register

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2009-06-07 at 12:00 +0200, Georg-Johann Lay wrote:
> Hi,
> 
> in the test cases
> 
> register unsigned char reg2 asm ("r2");

> 
> As gcc 3.4.6 behaves as expected (e.g. in bar, the access to reg2 
> remains in the loop), I wonder if this aggressive optimization is a bug?

> IMO that is a bug because reg2 is a fixed register and should therefore 
> be treated just like volatile. Unfortunately, gcc has nothing like 
> REG_VOLATILE_P to tag a reg being volatile, but as I said global fixed 
> registers should be treated that way.

Try adding a volatile to the variable:

register volatile unsigned char reg2 asm ("r2");

I would expect the accesses to be optimized out without it, because as
far as the compiler knows, the access can be hoisted out of the loop,
because the loop calls no other functions and the variable (register or
not) is not volatile.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux