Re: Using __int128 on 64-bit architectures

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

 



On Sun, 17 Mar 2013, H. Peter Anvin wrote:

> How desirable/portable is it to use __int128 on non-x86 64-bit
> architectures to get a 64*64 -> 128 bit multiply?  On x86-64 this works
> extremely well, but I'm worried about that needlessly breaking on other
> architectures.

 Hmm, nobody has replied, so just FYI such widening multiplication is 
available in all 64-bit MIPS hardware and GCC has supported it since 4.4 
or mid 2008 (older versions used a libgcc __multi3 helper, not quite so 
efficient as you can imagine).

$ cat mulditi3.c
typedef int int128_t __attribute__((mode(TI)));

int128_t mulditi3(long x, long y)
{
	int128_t _x = x, _y = y;
	return _x * _y;
}
$ mips64-linux-gcc -O2 -c mulditi3.c
$ mips64-linux-objdump -d mulditi3.o

mulditi3.o:     file format elf64-tradbigmips


Disassembly of section .text:

0000000000000000 <mulditi3>:
   0:	0085001c 	dmult	a0,a1
   4:	00001812 	mflo	v1
   8:	03e00008 	jr	ra
   c:	00001010 	mfhi	v0
$ 

(MFLO and MFHI are register moves from the MD accumulator to GPRs).  
There's an unsigned instruction variant as well.

 HTH,

  Maciej
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux