FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian GCC

 
 
LinkBack Thread Tools
 
Old 03-31-2010, 11:50 PM
Pierre Habouzit
 
Default Bug#576111: gcc-4.4 miscompiles __builtin_expect in -O0

For what it's worth, there is at least _another_ regression introduced
by the -4 or -5 revision in -O0, that I've not been able to track down
yet. I mean that when I remove all my uses of __builtin_expect in the
code that lead me to find out about this bug, I still have (at least)
another issue that pops up at the -O0 level that never shows up with any
other gcc release. And I deeply trust the mentioned code to be correct.
The code in question uses a lot of gcc __builtin_* functions if that
helps (ctz, clz, bswap among other).

On Thu, Apr 01, 2010 at 01:38:20AM +0200, Pierre Habouzit wrote:
> Package: gcc-4.4
> Version: 4.4.3-4
> Severity: grave
>
> Since gcc-4.4 version 4.4.3-4 (and yes -5 is still affected), gcc miscompiles
> __builtin_expect when no optimization is set (at least).
>
> Test case:
>
> int foo(int t) {
> if (__builtin_expect(t & 0x100, 0))
> return 0;
> return 1;
> }
>
>
> Bad assembly:
>
> gcc -O0 -S -o /dev/stdout a.c
> .file "a.c"
> .text
> .globl foo
> .type foo, @function
> foo:
> .LFB0:
> .cfi_startproc
> pushq %rbp
> .cfi_def_cfa_offset 16
> movq %rsp, %rbp
> .cfi_offset 6, -16
> .cfi_def_cfa_register 6
> movl %edi, -4(%rbp)
> movl -4(%rbp), %eax
> cltq
> andl $256, %eax
> movzbl %al, %eax <---------------------
> testq %rax, %rax
> je .L2
> movl $0, %eax
> jmp .L3
> .L2:
> movl $1, %eax
> .L3:
> leave
> ret
> .cfi_endproc
> .LFE0:
> .size foo, .-foo
> .ident "GCC: (Debian 4.4.3-5) 4.4.3"
> .section .note.GNU-stack,"",@progbits
>
> The buggy line is marked with the arrow.
> gcc-4.4 version 4.4.3-3 is correct and doesn't perform the buggy movzbl.

--
O Pierre Habouzit
O madcoder@debian.org
OOO http://www.madism.org



--
To UNSUBSCRIBE, email to debian-gcc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20100331235033.GF11893@laphroaig.corp">http://lists.debian.org/20100331235033.GF11893@laphroaig.corp
 

Thread Tools




All times are GMT. The time now is 07:05 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org