In GCC, there is a builtin called "__builtin_expect" that allows us to tell if we expect a branch to hit or not so the compiler can choose the branch prediction we want (unless I don't understand something correctly). Is there a way to do that in LDC?
Thread overview |
---|
May 10, 2022 Can we choose branch prediction like GCC? | ||||
---|---|---|---|---|
| ||||
May 10, 2022 Re: Can we choose branch prediction like GCC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to rempas | On Tuesday, 10 May 2022 at 10:02:21 UTC, rempas wrote: >Is there a way to do that in LDC? |
May 10, 2022 Re: Can we choose branch prediction like GCC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Tuesday, 10 May 2022 at 13:19:33 UTC, kinke wrote: >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):
I did tried for about half an hour but couldn't find anything... Any ideas how it works? |
May 10, 2022 Re: Can we choose branch prediction like GCC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to rempas | On Tuesday, 10 May 2022 at 20:31:41 UTC, rempas wrote: >I did tried for about half an hour but couldn't find anything... Any ideas how it works? As with gcc's __builtin_expect, one normally uses it in an if condition: |
May 11, 2022 Re: Can we choose branch prediction like GCC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Tuesday, 10 May 2022 at 22:34:23 UTC, kinke wrote: >As with gcc's __builtin_expect, one normally uses it in an if condition: Oh, how I didn't thought about trying this out.... Thank you! This will do the trick! Have an amazing day my friend! |