April 02, 2022
On Thursday, 31 March 2022 at 18:40:52 UTC, deadalnix wrote:
> On Thursday, 31 March 2022 at 06:31:32 UTC, Walter Bright wrote:
>> You see a similar thing when 32 bit compilation does 64 bit arithmetic:
>>
>> [...]
>>
>> So, yeah, supporting 128 bit arithmetic in the codegen has significant advantages. 3 multiplies and 2 adds.
>>
>> Having the compiler recognize the `mul` function as a builtin would enable this code gen for 128 bits.
>
> So now that you just killed the library solution by having the compiler specially recognize it, can we have cent/ucent?
>
> Honestly, I don't care if DMD forward the operation to something in druntime, that would at least allow me to have good codegen on LDC/GDC.

We can do the same as complex numbers here.

enum __c__int128 : core.int128.Cent;
enum __c__uint128 : core.int128.Cent;

Later, when cent/ucent have been dropped as keywords.

alias cent = __c__int128;
alias ucent = __c__uint128;


April 02, 2022
On Thursday, 31 March 2022 at 22:30:48 UTC, kinke wrote:
> On Thursday, 31 March 2022 at 18:40:52 UTC, deadalnix wrote:
>> Honestly, I don't care if DMD forward the operation to something in druntime, that would at least allow me to have good codegen on LDC/GDC.
>
> The existing generic software implementation is still useful for CTFE.

Yep, they were all written to be CTFE-friendly.
April 02, 2022
Another advantage to core.int128 is any soft implementation of a 128 bit integer does not need to concern itself with the correctness of the arithmetic - just the user side of the integer type.

I also like core.int128 does not import anything else, making it a true leaf module.

Edit: Oh darn, it imports core.bitop!
April 02, 2022
On Saturday, 2 April 2022 at 19:06:01 UTC, Walter Bright wrote:
> Another advantage to core.int128 is any soft implementation of a 128 bit integer does not need to concern itself with the correctness of the arithmetic - just the user side of the integer type.
>
> I also like core.int128 does not import anything else, making it a true leaf module.
>
> Edit: Oh darn, it imports core.bitop!

It's only bsr, the compiler inlines that into one instruction. ;-)
April 02, 2022
On 4/2/2022 2:40 PM, Iain Buclaw wrote:
> On Saturday, 2 April 2022 at 19:06:01 UTC, Walter Bright wrote:
>> Another advantage to core.int128 is any soft implementation of a 128 bit integer does not need to concern itself with the correctness of the arithmetic - just the user side of the integer type.
>>
>> I also like core.int128 does not import anything else, making it a true leaf module.
>>
>> Edit: Oh darn, it imports core.bitop!
> 
> It's only bsr, the compiler inlines that into one instruction. ;-)

I know. I was dreading doing the work you did for divide, glad you picked up the flag! I had done the equivalent for DMC's long divide long ago.
April 02, 2022
On 4/1/2022 7:23 AM, mee6 wrote:
>> Whoever does it first gets the glory :-)
> 
> I'd do it for money lol

What the hell, I'm tired of the jawboning and did it for the greater glory:

https://github.com/dlang/phobos/pull/8426
April 02, 2022

On Saturday, 2 April 2022 at 22:41:52 UTC, Walter Bright wrote:

>

On 4/1/2022 7:23 AM, mee6 wrote:

> >

Whoever does it first gets the glory :-)

I'd do it for money lol

What the hell, I'm tired of the jawboning and did it for the greater glory:

https://github.com/dlang/phobos/pull/8426

Thank you on behalf of myself. I wish I could a little support but I haven't gotten very far in D Language yet.

SDB@79

April 03, 2022

On Saturday, 2 April 2022 at 23:12:27 UTC, Salih Dincer wrote:

>

I wish I could a little support but I haven't gotten very far in D Language yet.

I don't know how to add it to Github. A small contribution, they work:

Lines,70-77

// ++Int128
    Int128 opUnary(string op)() const
        if (op == "++")
    {
        return Int128(inc(this.data));
    }
// --Int128
    Int128 opUnary(string op)() const
        if (op == "--")
    {
        return Int128(dec(this.data));
    }
//...
unittest {
    Int128 idTest;

    idTest += ulong.max;// hi = 1, lo = 0->
    assert(++idTest == Int128(1, 0));

    idTest = ++idTest;// hi = 0, lo = ulong.max->
    assert(--idTest == Int128(0, -1));
}

SDB@79

April 09, 2022
On 3/25/2022 4:33 PM, Murilo wrote:
> I have been waiting for years now, can't you guys just add these 2 types to the language?

Well, I tried.

https://github.com/dlang/phobos/pull/8426
April 11, 2022

On Friday, 1 April 2022 at 12:06:01 UTC, deadalnix wrote:

>

This is why a 128 bit type is absolutely key, it unlocks the ability to write larger integer types in a way that will allow the compiler to generate good code for it.

Does LLVM support that width good code gen? Intel/AMD have some instructions intended for higher precision math (ADX, MULX). They also have some instructions meant to be used for crypto, e.g. CLMUL.