News for hackers. Stuff that matters.
Re:C++ Attribute: Likely, Unlikely by shultays on Sunday October 22, 2023 @01:05PM (#37977092)
Any ideas how "likely" it needs to be benefit from likely? more than 50%? or 75%? or 90%? Can it be detrimental if it has higher changes but still close to 50%?
Re:C++ Attribute: Likely, Unlikely by UncleMeat on Sunday October 22, 2023 @01:13PM (#37977169)
Yes, you could imagine a bunch of scenarios where this could hurt you. Imagine a compiler that outlines the rare branch in order to shrink the code size of the function so that the hot path has better icache performance. That function call you inserted is expensive.
Re:C++ Attribute: Likely, Unlikely by o11c on Sunday October 22, 2023 @03:29PM (#37978320)
For GCC at least, 90% is what the optimizer assumes by default. With the GCC-specific version you can specify any arbitrary chance; specifyig 50% encourages `cmov`.