Standard way to supply hints to branches

kinke noone at nowhere.com
Fri Aug 23 20:08:53 UTC 2024


On Friday, 23 August 2024 at 09:10:34 UTC, Manu wrote:
> On Fri, 23 Aug 2024, 12:26 Nicholas Wilson via Digitalmars-d, < 
> digitalmars-d at puremagic.com> wrote:
>> For LDC see,
>>
>> https://github.com/ldc-developers/ldc/blob/master/runtime/druntime/src/ldc/intrinsics.di#L619 and see also `llvm_assume` just beneath it.
>>
>> GDC probably has something similar too.
>>
>
> Yes exactly, this is my point, we need something in the spec. I 
> think there might be an opportunity to express branch 
> prediction hints in a more user-friendly way than assume 
> statements... But a language assume() would also be very useful!

I suggest adding a `core.builtins.expect()` intrinsic to 
standardize the existing LDC and GDC intrinsics, adding a dummy 
(`pragma(inline, true)`!) identity function for DMD. No need for 
introducing statement-level UDAs, other compiler magic, 
complicating language/spec etc. `core.attribute` already does 
this for magic UDAs.


More information about the Digitalmars-d mailing list