Passing long long to asm generates internal error

Peter Osterlund peter.osterlund@mailbox.swipnet.se
Sat May 1 10:45:00 GMT 1999


I'm trying to pass a long long argument to an asm block. (i686, linux).
This seems to work most of the time, but in some cases I get an internal
error (unrecognizable insn) from the compiler. I'm using the "A"
constraint to pass the long long in the eax and edx registers. Is this
correct? Is there a better way to pass a long long to asm code?

By the way, this code compiles with gcc 2.7.2, but maybe that is
irrelevant.

[petero@ppro petero]$ cat bug.c
extern long long v[];

void f()
{
    long long tmp = v[0];
    while (tmp) {
        int result;
        int file;
        __asm__ ("
        bsr     %%edx, %1
        movl    $31, %0
        jnz     0f
        bsr     %%eax, %1
        movl    $63, %0
        jnz     0f
        movl    $-1, %1
0:      subl    %1, %0"
             : "=&r" (result), "=&r" (file)
             : "A" (tmp));
        file = result;
        if (v[0] & v[file])
            file = 0;
        tmp = v[file];
    }
}
[petero@ppro petero]$ gcc -v -O bug.c
Reading specs from /home/petero/egcs/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.20/
specs
gcc version egcs-2.93.20 19990501 (gcc2 ss-980929 experimental)
 /home/petero/egcs/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.20/cpp -lang-c -v -D_
_GNUC__=2 -D__GNUC_MINOR__=93 -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__
unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__OPTIMIZE__ 
-Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i
686 -D__i686__ -D__pentiumpro -D__pentiumpro__ bug.c /tmp/ccSehaaa.i
GNU CPP version egcs-2.93.20 19990501 (gcc2 ss-980929 experimental) (i386 Linux/
ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /home/petero/egcs/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.20/../../../../i686-p
c-linux-gnu/include
 /home/petero/egcs/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.20/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /home/petero/egcs/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.20/../../../../includ
e/g++-2
End of omitted list.
 /home/petero/egcs/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.20/cc1 /tmp/ccSehaaa.
i -quiet -dumpbase bug.c -O -version -o /tmp/ccAjoaaa.s
GNU C version egcs-2.93.20 19990501 (gcc2 ss-980929 experimental) (i686-pc-linux
-gnu) compiled by GNU C version egcs-2.93.20 19990501 (gcc2 ss-980929 experiment
al).
bug.c: In function `f':
bug.c:25: internal error--unrecognizable insn:
(insn 25 23 28 (parallel[ 
            (set (reg/v:SI 0 %eax)
                (asm_operands ("
        bsr     %%edx, %1
        movl    $31, %0
        jnz     0f
        bsr     %%eax, %1
        movl    $63, %0
        jnz     0f
        movl    $-1, %1
0:      subl    %1, %0") ("=&r") 0[ 
                        (reg:DI 1 %edx)
                    ] 
                    [ 
                        (asm_input:DI ("A"))
                    ]  ("bug.c") 19))
            (set (reg/v:SI 3 %ebx)
                (asm_operands ("
        bsr     %%edx, %1
        movl    $31, %0
        jnz     0f
        bsr     %%eax, %1
        movl    $63, %0
        jnz     0f
        movl    $-1, %1
0:      subl    %1, %0") ("=&r") 1[ 
                        (reg:DI 1 %edx)
                    ] 
                    [ 
                        (asm_input:DI ("A"))
                    ]  ("bug.c") 19))
        ] ) -1 (nil)
    (nil))

-- 
Peter Österlund          Email:     peter.osterlund@mailbox.swipnet.se
Sköndalsvägen 35                    f90-pos@nada.kth.se
S-128 66 Sköndal         Home page: http://home1.swipnet.se/~w-15919
Sweden                   Phone:     +46 8 942647



More information about the Gcc-bugs mailing list