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]

volatile and R/M/W operations


When looking at an Ada PR, I stumbled upon the equivalent of the
following C code:

unsigned char x;
volatile unsigned char y;

void f ()
{
        x |= 16;
        y |= 32;
}

With trunk/i686, the following code is generated (-O3 -fomit-frame-pointer):

f:
        movzbl  y, %eax
        orb     $16, x
        orl     $32, %eax
        movb    %al, y
        ret

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?
(in which case I will open a PR)

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/


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