workaround gcc-4 assembly constraint bug

Toshio toshio at tiki-lounge.com
Mon May 16 14:30:46 UTC 2005


I've been working on getting the ocaml extras package compiled on devel:
  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=156238
There appears to be a bug in gcc4's inline assembly constraints:
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21291
that's keeping the compiler from selecting memory when we run out of
registers.  Here's the affected ocaml code from:
ocaml-3.08.3/otherlibs/num/bng_ia32.c:bngdigit bng_ia32_mult_sub_digit:

    asm("1: \n\t"
        "movl (%1), %%eax \n\t"
        "movl (%0), %4 \n\t"
        "mull %5\n\t"           /* edx:eax = d * next digit of b */
        "subl %%eax, %4 \n\t"   /* subtract eax from next digit of a */
        "adcl $0, %%edx \n\t"   /* accumulate carry in edx */
        "subl %3, %4 \n\t"      /* subtract out */
        "adcl $0, %%edx \n\t"   /* accumulate carry in edx */
        "movl %4, (%0) \n\t"    /* store next digit of result */
        "movl %%edx, %3 \n\t"   /* edx is next out */
        "leal 4(%0), %0 \n\t"
        "leal 4(%1), %1 \n\t"
        "decl %2 \n\t"
        "jnz 1b"
        : "+&r" (a), "+&r" (b), "+&rm" (blen), "+&rm" (out), "=&r" (tmp)
        : "rm" (d)
        : "eax", "edx");

I think that the solution should be to change the constraints to specify
memory only rather than a register with memory fallback:

        : "+&r" (a), "+&r" (b), "+m" (blen), "+m" (out), "=&r" (tmp)
        : "rm" (d)
        : "eax", "edx");

I'm not too familiar with gcc's constraints, though.  Would anyone with
a bit more experience be willing to tell me if that looks right or not?

Thanks,
Toshio
-- 

toshio \ 25th March, 1999:  Cold rain in Georgia.  Blustery blowing wind.
 @tiki  \ Freezing fingers and tired body.  Hiking on because the shelters
 -lounge \ are filled with other hikers.
 .com     \__________Life is miserable -- Life is grand!_______ GA->ME 1999
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/fedora-devel-list/attachments/20050516/0bba9ac5/attachment.sig>


More information about the fedora-devel-list mailing list