Standard way to supply hints to branches

Quirin Schroll qs.il.paperinik at gmail.com
Fri Sep 6 10:53:10 UTC 2024


On Thursday, 29 August 2024 at 18:28:04 UTC, Walter Bright wrote:
> On 8/28/2024 2:45 AM, Manu wrote:
>> Here's one that I just wrote a short while ago:
>> https://gist.github.com/TurkeyMan/0e49da245cc0086f852ac18deed21a9c
>
>
> ```
> if (data.length < 4) // unlikely
>     return 0;
> ```
>
> replace with:
>
> ```
> if (data.length < 4)
>     goto Lreturn0;
> ```

Prime example of Hyrum’s Law.

Heuristics in the optimizer: Good.
Pandering to the heuristics of a specific compiler: Bad.


More information about the Digitalmars-d mailing list