News for hackers. Stuff that matters.
Re:Intel's Redwood Cove: Baby Steps Are Still Steps by jeffbee on Monday September 23, 2024 @10:52AM (#41626788)
I can see how branch hints are useful, but in practice isn't the sign of the distance to the branch target the implicit hint? If the predictor doesn't have any other information it assumes that backwards branches are taken and forward branches are not. So, you can imagine how the compiler would rearrange the program to align with that implication, where possible.

One of the things that the BOLT post-link optimizer does is rearrange basic blocks to reduce taken forward branches, based on the profiles.

Re:Intel's Redwood Cove: Baby Steps Are Still Steps by marcosdumay on Monday September 23, 2024 @01:00PM (#41628158)
You can't reorder some kinds of branches, like retry sequences.

I have absolutely no idea how important that it. But there exist that bit of extra complication on the real world.

Re:Intel's Redwood Cove: Baby Steps Are Still Steps by taeric on Monday September 23, 2024 @04:59PM (#41630486)
Retry sequences are unlikely to be the kind that the branch prediction is that important? I'd also expect that they are larger than the threshold that is common for branches that are likely to be taken many times.

That is, the stuff that will go into a retry of something likely has far more setup than your typical hot loop.

Re:Intel's Redwood Cove: Baby Steps Are Still Steps by bee_rider on Monday September 23, 2024 @01:39PM (#41628566)
Huh, that’s a funny and true perspective. I always took the “branches backwards tend to be loops” assumption as true, but of course there’s no reason a compiler or linker couldn’t use that assumption as well.
Re:Intel's Redwood Cove: Baby Steps Are Still Steps by BeeOnRope on Tuesday September 24, 2024 @11:41PM (#41643481)
Yes I don't really get it. For non-loop branches if the compiler has knows enough to insert a branch hint it would also already arrange the generated code so that was the fall through cases, which is already much more efficient when predicted and aligns the default fall through assumption in the CPU.