From: Lili Cui Date: Wed, 24 Jun 2026 07:05:31 +0000 (-0700) Subject: x86: Increase generic tune branch misprediction cost X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=52cd02606b906160bf47001a00b446c35d46f15f;hp=76f4dd2c8f296a950f4cac04fa9a30ae0892cdb9 x86: Increase generic tune branch misprediction cost Increase the branch misprediction scale for generic tuning from COSTS_N_INSNS (2) to COSTS_N_INSNS (2) + 3. Modern CPUs have deeper pipelines, making branch mispredictions more expensive. Increasing this cost encourages if-conversion, avoiding pipeline stalls from mispredicted branches. This improves 544.nab_r (-O2) by 12.7% on GNR and 12.1% on Znver5 with single-copy. gcc/ChangeLog: * config/i386/x86-tune-costs.h (generic_cost): Increase branch mispredict scale from COSTS_N_INSNS (2) to COSTS_N_INSNS (2) + 3. --- diff --git a/gcc/config/i386/x86-tune-costs.h b/gcc/config/i386/x86-tune-costs.h index cc9de64394e0..bc3bb6943491 100644 --- a/gcc/config/i386/x86-tune-costs.h +++ b/gcc/config/i386/x86-tune-costs.h @@ -4274,7 +4274,7 @@ struct processor_costs generic_cost = { "16", /* Func alignment. */ 4, /* Small unroll limit. */ 2, /* Small unroll factor. */ - COSTS_N_INSNS (2), /* Branch mispredict scale. */ + COSTS_N_INSNS (2) + 3, /* Branch mispredict scale. */ }; /* core_cost should produce code tuned for Core family of CPUs. */