http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59968

--- Comment #12 from H.J. Lu <hjl.tools at gmail dot com> ---
For

int bar1;
void
__attribute__((noinline))
foo1 (int y)
{
  int z;
  if (!(bar1 & (1 << y)))
    xxx1 ();
  z = bar1 & (1 << y);
  bar1 |= 1 << y;
  bar1 &= ~z;
}

we generate

    movl    bar1(%rip), %edx
    pushq    %rbx
    .cfi_def_cfa_offset 16
    .cfi_offset 3, -16
    movl    %edi, %ebx
    btl    %edi, %edx
    jc    .L3
    call    xxx1
    movl    bar1(%rip), %edx
.L3:
    movl    %ebx, %ecx
    movl    $1, %eax
    sall    %cl, %eax
    movl    %edx, %ecx
    andl    %eax, %ecx
    orl    %edx, %eax
    notl    %ecx
    andl    %ecx, %eax
    movl    %eax, bar1(%rip)
    popq    %rbx
    .cfi_def_cfa_offset 8
    ret

I expect

    btc %edi, bar2(%rip)
    jc .L7
    jmp    xxx2
.L8:
    .p2align 4,,10
    .p2align 3
.L7:
    rep ret

Reply via email to