https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110177

--- Comment #3 from Theodoros Theodoridis <theodort at inf dot ethz.ch> ---
I think the correct bisection is: r11-3063-gfcae5121154 (or its parent
r11-3062-g90e88fd376b)
I can't build its parent but with its grandparent r11-3061-g1644d7f4c1c the
call to foo is eliminated:

gcc-1644d7f4c1c4f99231d7de5e35fa7ce2d2e2c4c6 -Os test.c -S -o /dev/stdout

main:
        movq    g(%rip), %rax
        movl    $0, c(%rip)
        movq    (%rax), %rdx
        movq    %rdx, f(%rip)
        testq   %rdx, %rdx
        je      .L2
        movq    (%rax), %rax
        movq    %rax, f(%rip)
        testq   %rax, %rax
        jne     .L8
        movl    $9, c(%rip)
.L2:
        pushq   %rax
        xorl    %eax, %eax
        call    __assert_fail
.L8:
        movl    $27, c(%rip)
        xorl    %eax, %eax
        movl    $0, e(%rip)
        ret


r11-3063-gfcae5121154 with ranger disabled generates the same code

gcc-fcae5121154d1c3382b056bcc2c563cedac28e74 -Os test.c -S -o /dev/stdout:

main:
        movq    g(%rip), %rax
        movl    $0, c(%rip)
        movq    (%rax), %rdx
        movq    %rdx, f(%rip)
        testq   %rdx, %rdx
        je      .L2
        movq    (%rax), %rax
        movq    %rax, f(%rip)
        testq   %rax, %rax
        jne     .L8
        movl    $9, c(%rip)
.L2:
        pushq   %rax
        xorl    %eax, %eax
        call    __assert_fail
.L8:
        movl    $27, c(%rip)
        xorl    %eax, %eax
        movl    $0, e(%rip)
        ret

with ranger enabled it doesn't eliminate the call and generates mode code:
gcc-fcae5121154d1c3382b056bcc2c563cedac28e74 -Os -fevrp-mode=ranger test.c -S
-o /dev/stdout:

main:
        pushq   %rcx
        movl    e(%rip), %edi
        xorl    %eax, %eax
        xorl    %edx, %edx
        movl    $0, c(%rip)
        movq    g(%rip), %r8
.L2:
        movl    %eax, %esi
        cmpl    $27, %eax
        je      .L20
        testl   %eax, %eax
        je      .L3
        movl    %edi, %ecx
        movl    %eax, %r9d
        movl    %eax, %r10d
        sall    %cl, %r9d
        movl    %r9d, %ecx
        sarl    %cl, %r10d
        testw   %r10w, %r10w
        je      .L3
        movl    %eax, c(%rip)
.L3:
        movq    (%r8), %rcx
        addl    $9, %eax
        movq    %rcx, f(%rip)
        testq   %rcx, %rcx
        jne     .L8
        testb   %dl, %dl
        je      .L4
        movl    %esi, c(%rip)
.L4:
        xorl    %eax, %eax
        call    __assert_fail
.L8:
        movb    $1, %dl
        jmp     .L2
.L20:
        testb   %dl, %dl
        je      .L6
        movl    $27, c(%rip)
.L6:
        cmpq    $0, f(%rip)
        movl    $0, e(%rip)
        jne     .L7
        call    foo
.L7:
        xorl    %eax, %eax
        popq    %rdx
        ret

Reply via email to