News for hackers. Stuff that matters.
Re:Why is Rosetta 2 fast? by astrange on Thursday November 10, 2022 @12:28AM (#33542611)
There are no ways to hint the branch predictor on some common CPUs. I think Intel says it's fully dynamic and has no static predictions.

If you want to cause a pipeline stall, there's usually serializing instructions like cpuid/eieio.

Re:Why is Rosetta 2 fast? by vgatherps on Thursday November 10, 2022 @12:34AM (#33542661)
I believe intel used to always predict forward branches not taken and backward branches always taken if it didn’t have any history.

Regardless, you can at least lay out code in a way that heavily favors one branch over the other, and potentially optimize for one branch (I.e. give one branch very expensive prelude/exit to make another branch very cheap). The last thing I’ve seen compilers greatly struggle with though…