[Bug middle-end/58387] wrong code at -Os and above on x86_64-linux-gnu (both 32-bit and 64-bit modes)

su at cs dot ucdavis.edu gcc-bugzilla@gcc.gnu.org
Wed Sep 11 07:10:00 GMT 2013


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

--- Comment #4 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Jakub Jelinek from comment #3)
> Not even with r202421.
> Content of main with that revision for x86_64 -Os is:
> 	.cfi_startproc
> 	pushq	%rcx
> 	.cfi_def_cfa_offset 16
> 	movl	a(%rip), %esi
> 	testl	%esi, %esi
> 	je	.L4
> 	negl	%esi
> 	testl	%esi, %esi
> 	jg	.L3
> 	jmp	.L2
> .L4:
> 	xorl	%esi, %esi
> .L2:
> 	movl	$.LC0, %edi
> 	xorl	%eax, %eax
> 	call	printf
> .L3:
> 	xorl	%eax, %eax
> 	popq	%rdx
> 	.cfi_def_cfa_offset 8
> 	ret


Here is what I have for x86_64 -Os: 

    .cfi_startproc
    pushq    %rax
    .cfi_def_cfa_offset 16
    xorl    %esi, %esi
    movl    $.LC0, %edi
    xorl    %eax, %eax
    call    printf
    xorl    %eax, %eax
    popq    %rdx
    .cfi_def_cfa_offset 8
    ret
    .cfi_endproc


Below is what I have for x86_64 -O1: 

    .cfi_startproc
    subq    $8, %rsp
    .cfi_def_cfa_offset 16
    movl    a(%rip), %eax
    testl    %eax, %eax
    je    .L2
    negl    %eax
    testl    %eax, %eax
    jg    .L3
.L2:
    movl    $0, %esi
    movl    $.LC0, %edi
    movl    $0, %eax
    call    printf
.L3:
    movl    $0, %eax
    addq    $8, %rsp
    .cfi_def_cfa_offset 8
    ret
    .cfi_endproc


More information about the Gcc-bugs mailing list