avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] Converting unsigned long to float... OUCH!


From: Ben Jackson
Subject: [avr-gcc-list] Converting unsigned long to float... OUCH!
Date: Fri, 29 Jul 2005 00:19:40 -0700
User-agent: Mutt/1.5.6i

Please bear with my near-complete ignorance of gcc internals here, but
I think I have worked out that SOMEWHERE (avr.md???) we are not providing
a unsigned long to float conversion, so we get an automatic fallback
created by optabs.c expand_float() (again, heavy dose of ??? since I
don't look inside gcc much):

  /* Unsigned integer, and no way to convert directly.
     Convert as signed, then conditionally adjust the result.  */
  if (unsignedp)
        ...

This seems to generate code to pry the high bit off of the input
operand, convert the 31 bit part as a signed value, and then add
back the extra bit... CONDITIONALLY!  Here is the result:

I'm pretty sure we could do better with a asm stub in libm, but how
do we make gcc use it?

        lds r18,u
        lds r19,(u)+1
        lds r20,(u)+2
        lds r21,(u)+3
        sbrc r21,7
        rjmp .L29
        mov r25,r21
        mov r24,r20
        mov r23,r19
        mov r22,r18
        rcall __floatsisf
        rjmp .L35
.L29:
        mov r25,r21
        mov r24,r20
        mov r23,r19
        mov r22,r18
        andi r22,lo8(1)
        andi r23,hi8(1)
        andi r24,hlo8(1)
        andi r25,hhi8(1)
        lsr r21
        ror r20
        ror r19
        ror r18
        or r22,r18
        or r23,r19
        or r24,r20
        or r25,r21
        rcall __floatsisf
        mov r18,r22
        mov r19,r23
        mov r20,r24
        mov r21,r25
        rcall __addsf3
.L35:
        mov r14,r22
        mov r15,r23
        mov r16,r24
        mov r17,r25

-- 
Ben Jackson
<address@hidden>
http://www.ben.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]