From Jason Turner
Watch on YouTube

Summary

Jason examines C++20's new [[likely]] and [[unlikely]] attributes, which provide branch prediction hints to the compiler. These attributes allow developers to mark conditional branches they expect to be frequently or rarely taken, potentially improving performance by helping the compiler optimize code generation. While simple examples showed minimal differences in generated assembly, a more complex real-world scenario demonstrated how these attributes can influence register allocation and instruction ordering, potentially improving performance for hot code paths.

Resources

Tags