GCC & LLVM/Clang Compilers Updated For Intel Branch Hint

Written by Michael Larabel in Intel on 8 July 2024 at 06:06 AM EDT. Add A Comment
INTEL
Both the GCC and LLVM/Clang compilers today saw support for Intel's Branch Hint extension merged today for this feature of Redwood Cove P cores as found with current generation Meteor Lake processors as well as upcoming Intel Granite Rapids server processors.

One of the many new features with the Redwood Cove microarchitecture is the Branch Hint x86 architecture extension. The Branch Hint is described within Intel's documentation as:
"Starting with the Redwood Cove microarchitecture, if the predictor has no stored information about a branch, the branch has the Intel SSE2 branch taken hint (i.e., instruction prefix 3EH), When the codec decodes the branch, it flips the branch’s prediction from not-taken to taken. It then flushes the pipeline in front of it and steers this pipeline to fetch the taken path of the branch.
...
The hint is only used when the predictor does not have stored information about the branch. To avoid code bloat and reducing the instruction fetch bandwidth, don’t add the hint to a branch in hot code—for example, a branch inside a loop with a high iteration count—because the predictor will likely have stored information about that branch. Ideally, the hint should only be added to infrequently executed branches that are mostly taken, but identifying those branches may be difficult. Compilers are advised to add the hints as part of profile-guided optimization, where the one-sided execution path cannot be laid out as a fall-through. The Redwood Cove microarchitecture introduces new performance monitoring events to guide hint placement.

Judiciously adding hints can reduce the program’s run time by reducing the branch misprediction penalty. Hints are especially useful for large code footprint workloads where the number of branches exceeds the predictor's capacity."

Intel Branch Hint documentation


LLVM has merged support for x86 Branch Hint. The GCC compiler also saw new code merged today for dealing with this Branch Hint capability on Redwood Cove cores. LLVM 19 is currently under development for debut around September while GCC Git is tracking for next year's GCC 15 release.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week