www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - LDC asm for int128

reply Newbie2019 <newbie2019 gmail.com> writes:
I want to translate this c code into d (build with ldc), so I can 
use -flto and inline with other code.

uint64_t _wymum(uint64_t A, uint64_t B){
         __uint128_t r = A ;
         r *= B;
         return  (r>>64)^r;
}

Do i need ASM or is there a easy way to implement it ?
Sep 09 2019
next sibling parent a11e99z <black80 bk.ru> writes:
On Tuesday, 10 September 2019 at 06:18:05 UTC, Newbie2019 wrote:
 I want to translate this c code into d (build with ldc), so I 
 can use -flto and inline with other code.

 uint64_t _wymum(uint64_t A, uint64_t B){
         __uint128_t r = A ;
         r *= B;
         return  (r>>64)^r;
 }

 Do i need ASM or is there a easy way to implement it ?
https://forum.dlang.org/post/ighiwexofvdqbuqeqbkp forum.dlang.org
Sep 10 2019
prev sibling parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Tuesday, 10 September 2019 at 06:18:05 UTC, Newbie2019 wrote:
 I want to translate this c code into d (build with ldc), so I 
 can use -flto and inline with other code.

 uint64_t _wymum(uint64_t A, uint64_t B){
         __uint128_t r = A ;
         r *= B;
         return  (r>>64)^r;
 }

 Do i need ASM or is there a easy way to implement it ?
Easiest way is to use GFM's[1] 128bit integers. [1]:http://code.dlang.org/packages/gfm
Sep 10 2019