Can we choose branch prediction like GCC?

rempas rempas at tutanota.com
Tue May 10 20:31:41 UTC 2022


On Tuesday, 10 May 2022 at 13:19:33 UTC, kinke wrote:
> Yes: 
> https://github.com/ldc-developers/druntime/blob/bf27af6ef6dab9e45f005f67cc42e3a3bb393623/src/ldc/intrinsics.di#L616-L624

Thank you for your answer! However, I'm trying to understand how 
it works but I cannot seem to get it. I'm trying to do something 
like the following but it seems that it doesn't work (as it makes 
sense):

```
import ldc.intrinsics;
import core.stdc.stdio;

extern (C) void main() {
   int x = 0;
   llvm_expect(x < 10, 0) {
     printf("x is less than 10!\n");
   }
}
```

I did tried for about half an hour but couldn't find anything... 
Any ideas how it works?


More information about the digitalmars-d-ldc mailing list