NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-vax/46677: gcc bug with builtin ffs on vax.

>Number:         46677
>Category:       port-vax
>Synopsis:       gcc bug with builtin ffs on vax.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-vax-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 09 15:45:00 +0000 2012
>Originator:     Anders Magnusson
>Release:        6.0 beta2
NetBSD 6.0_BETA2 NetBSD 6.0_BETA2 (GENERIC) #10: Mon Jul  
9 17:02:03 CEST 2012  

The builtin ffs function fails in some situations for gcc both 4.1 or 4.5, and 
both native and cross-compiled.

The code example below shows that the second ffs gets optimized away.

vs4090:/home/ragge >cat x.c

struct foo { long __bits[4]; };

firstsig(struct foo *ss)
        int sig;

        sig = ffs(ss->__bits[0]);
        if (sig != 0)
                return (sig);

        sig = ffs(ss->__bits[1]);
        if (sig != 0)
                return (sig + 32);

        return (0);

vs4090:/home/ragge >gcc -S -O2 x.c
vs4090:/home/ragge >cat x.s
        .file   "x.c"
        .align 1
.globl firstsig
        .type   firstsig, @function
        .word 0x0
        subl2 $4,%sp
        ffs $0,$32,*4(%ap),%r0
        jneq .L2
        mnegl $1,%r0
        incl %r0
        .size   firstsig, .-firstsig
        .ident  "GCC: (GNU) 4.1.3 20080704 prerelease (NetBSD nb3 20111107)"


Home | Main Index | Thread Index | Old Index