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

--- Comment #2 from Avi Kivity <avi at scylladb dot com> ---
(In reply to Andrew Pinski from comment #1)
> But the assembly output does not make sense to the code you gave either.


Apart from the missing .section directives, I didn't notice anything odd. Maybe
movl/testl could be optimized into cmpl.

Ah, I moved this code from C++ so the function signatures are bad, should be
fun(void). With the signatures adjusted, I get

light:
.LFB2:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        call    fun
        movl    f1(%rip), %edx
        testl   %edx, %edx
        jne     .L8
.L6:
        addq    $8, %rsp
        .cfi_remember_state
        .cfi_def_cfa_offset 8
        jmp     fun
        .p2align 4,,10
        .p2align 3
.L8:
        .cfi_restore_state
        movl    f2(%rip), %eax
        testl   %eax, %eax
        je      .L6
        call    very_heavy
        jmp     .L6
        .cfi_endproc


Which still misses the .section directives and the peephole optimization to
merge movl/testl.

Reply via email to