This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: volatile and R/M/W operations
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: sam at rfc1149 dot net
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 30 Nov 2007 17:24:13 EST
- Subject: Re: volatile and R/M/W operations
- References: <2007-11-30-23-19-02+trackit+sam@rfc1149.net>
> volatile unsigned char y;
> void f ()
> {
> y |= 32;
> }
>
> I cannot see a reason not to use "orb $32,y" here instead of a three
> steps read/modify/write operation. Is this only a missed optimization?
No, it's purposeful. The idea was that this is completely equivalent to
y = y | 32;
That does two memory operations and it's volatile, so we want to as well.
Now in some sense, so does "orb $32,y", but we want to play it safe.
For almost all purposes, saying "volatile" means to turn off all optimizations
involving that object and I don't think we want to change that at this point
because of the possible damage to legacy code.