On Wed, Jul 3, 2024 at 2:10 AM Andi Kleen <a...@linux.intel.com> wrote: > > liuhongt <hongtao....@intel.com> writes: > > > From: "H.J. Lu" <hjl.to...@gmail.com> > > > > According to Intel® 64 and IA-32 Architectures Optimization Reference > > Manual[1], Branch Hint is updated for Redwood Cove. > > > > --------cut from [1]------------------------- > > 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. > > --------cut end ----------------------------- > > > > For -mtune-ctrl=branch_prediction_hints, always generate branch hint for > > conditional branches, this tune is disabled by default. > > > > [1] > > https://www.intel.com/content/www/us/en/content-details/821612/intel-64-and-ia-32-architectures-optimization-reference-manual-volume-1.html > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > > Ready push to trunk. > > So what does it do to code size? > You may not want to do it with -Os. It won't be enabled by Os, because it's guarded by
if (!optimize || optimize_function_for_size_p (cfun) || !TARGET_BRANCH_PREDICTION_HINTS) return; > > Maybe it should be only done with actual profile feedback data > available, i'm not sure if the builtin heuristics are good enough to > justify it and there is a risk that it is very wrong. Yes, best used with a PGO. > > Yes as long as it's disabled by default that's all not a problem, but it > would need to be solved to enable it. > > -Andi -- BR, Hongtao