News for hackers. Stuff that matters.
Re:Intel's Redwood Cove: Baby Steps Are Still Steps by duskwuff on Monday September 23, 2024 @02:16AM (#41622807)
Usually not by default, but GCC and other compilers have intrinsics like __builtin_expect [1] which may generate branch hints.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index...

Re:Intel's Redwood Cove: Baby Steps Are Still Steps by unwind on Monday September 23, 2024 @04:15AM (#41623626)
Quite popular in the Linux kernel code, as far as I've seen over the years. See [1] for some discussion over on SO.

[1]: https://stackoverflow.com/questions/109710

Re:Intel's Redwood Cove: Baby Steps Are Still Steps by menaerus on Monday September 23, 2024 @07:52AM (#41625085)
In practice this doesn't result with a special-kinded instruction to hint the CPU branch-predictor but only affects the compiler to generate a codegen that is optimized for better CPU instruction-cache utilization. E.g. it will try to move the less likely code out from the hot code path and as such the likely code is going to be more dense and co-located next to each other.
Re:Intel's Redwood Cove: Baby Steps Are Still Steps by vlovich123 on Monday September 23, 2024 @11:59AM (#41627489)
It can also change the instruction selection. For example, __builtin_unpredictable which is a close cousin of expect will indicate there's no prediction possible on a branch. This causes the compiler to select branchless instructions & is particularly useful in things like binary search where the CPU attempting to do prediction is worse than using a branchless version of the code.
Re:Intel's Redwood Cove: Baby Steps Are Still Steps by Salgat on Tuesday September 24, 2024 @12:49PM (#41638423)
I think in general we're overdue for more compiler directives, and not just branch hints. As heterogenous architectures become more standard, we really need a way to tag what functions are best to run with what types of instructions. For example, tag a function that will utilize SIMD so that if a thread is running this function, the operating system knows to try to have it run on the cores that support SIMD. As of now, with P and E Cores for Intel, Intel is straight up disabling instructions to ensure uniform instruction support.