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

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

 



David Hagood schrieb:
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");

That has no effect. Note that register is not a mem. Older versions of gcc reported a warning on volatile register like "effect is not what you might expect". Moreover, gcc cannot track volatile registers.
rtl.h reads:

/* 1 in a MEM or ASM_OPERANDS expression if the memory reference is volatile.
     1 in an INSN, CALL_INSN, JUMP_INSN, CODE_LABEL, BARRIER, or NOTE
     if it has been deleted.
1 in a REG expression if corresponds to a variable declared by the user,
     0 for an internally generated temporary.
     1 in a SUBREG with a negative value.
     1 in a LABEL_REF, REG_LABEL_TARGET or REG_LABEL_OPERAND note for a
     non-local label.
     In a SYMBOL_REF, this flag is used for machine-specific purposes.  */
  unsigned int volatil : 1;

What gcc knows is that some registers are or may be fixed, so it should care about that.

Georg-Johann


[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