Subject: Re: smull

From: Nicolas Pitre <[email-masked]>
Date: Sat, 31 Jul 1999 20:59:00 -0400 (EDT)

On Sat, 31 Jul 1999, Philip Blundell wrote:

> >Any ideas how to trigger a smull from C code?
> 
> Something like this:
> 
> long long foo(long a, long b)
> {
>   return (long long)a*(long long)b;
> }
> 
> foo:
>         @ args = 0, pretend = 0, frame = 0
>         @ frame_needed = 0, current_function_anonymous_args = 0
>         smull   r2, r3, r0, r1
>         mov     r1, r3
>         mov     r0, r2
>         mov     pc, lr

Unfortunately, I can't get better than this with the code above:

foo:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, current_function_anonymous_args = 0
        stmfd   sp!, {r4, r5, lr}
        mov     r2, r1
        mov     r3, r2, asr #31
        mov     r4, r0
        mov     r5, r4, asr #31
        mov     r1, r5
        mov     r0, r4
        ldmfd   sp!, {r4, r5, lr}
        b       __muldi3

a and b are always promoted to long long before the multiplication takes
place...  Any idea?

Nicolas Pitre, B. ing.
[email-masked]

unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Philip Blundell <[email-masked]>
Date: Sun, 01 Aug 1999 09:40:30 +0100

>a and b are always promoted to long long before the multiplication takes

What version of GCC and what command line options are you using?  Check for 
example that you have enabled ARMv4 instructions.

p.

---

From: Dave Gilbert <[email-masked]>
Date: Sun, 1 Aug 1999 14:28:18 +0100 (BST)

> >   return (long long)a*(long long)b;

Shouldn't that be

long long foo(int a, int b)
{
  return (long long)(a*b);
}

smull taking 32 bit values and giving a 64 out?

Dave

 --------------------------------------------------------------------   
/ Dr. David Alan Gilbert      | Running Linux on           |  Happy  \ 
\   gro.gilbert @ treblig.org |  Alpha, x86, ARM and SPARC |  In Hex /
 ____________________________|___ http://www.treblig.demon.co.uk __/

---

From: Philip Blundell <[email-masked]>
Date: Sun, 01 Aug 1999 14:57:01 +0100

>smull taking 32 bit values and giving a 64 out?

Emperically, no -- that calculates a 32-bit product and then sign extends to 
64 bits.  I don't have a copy of the standard on hand to see what it says 
about automatic promotion in cases like this.

p.

---

From: Nicolas Pitre <[email-masked]>
Date: Sun, 1 Aug 1999 11:48:34 -0400 (EDT)

> example that you have enabled ARMv4 instructions.

Aaaahhhh!  Right...  Forgot about ARMv4.

Thanks!

Nicolas Pitre, B. ing.
[email-masked]