Why it worked
The video explains a complex technical concept (CPU branch prediction optimization) in an accessible way, using clear visuals and relatable analogies. The "hack" aspect and the significant performance increase (12%) make it compelling for tech enthusiasts.
Summary
An Intel engineer discovered a way to increase CPU speed by 12% by making a minor change to the GCC compiler. This change adjusts how the compiler penalizes incorrect branch predictions, encouraging it to use branchless code more often, which reduces idle time and improves performance.
On-screen text
AMD Ryzen 5 7600
Faster CPUs From Just Adding Three
author
Lili Cui <lili.cui@intel.com>
committer
Cui, Lili <lili.cui@intel.com>
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 (-02) by 12.7% on GNR and 12.1% on Zmver5 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.
gcc/config/i386/x86-tune-costs.h
patch | blob | history
diff --git a/gcc/config/i386/x86-tune-costs.h b/gcc/config/i386/x86-tune-costs.h
index cc9de64394e073cfe86b5c3d91b26aeb9434b8fd..bc3bb69434919d855e6a81e40bc9b
--- 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",
4,
2,
- COSTS_N_INSNS (2),
+ COSTS_N_INSNS (2) + 3, /* Branch mispredict scale. */
};
/* core_cost should produce code tuned for Core family of CPUs. */
GNU Compiler Collection
branch.c
1 if (temperature > 100) {
2 coolDown();
3 } else {
4 keepRunning();
5 }
delivery.c
1 int delivery(int total) {
2 int fee;
3 if (total > 499) {
4 fee = 0;
5 } else {
6 fee = 40;
7 }
8 return fee;
}
pick.c
1 int pick(int a, int b, int x, int y) {
2 int r;
3 if (a < b) {
4 r = x * 3 + 7;
5 } else {
6 r = y * 5 - 2;
7 }
8 return r;
}
CPUs and fast AI with Vector Neural Network Instructions
Hongtao Liu, GCC x86 Backend Vector Maintainer, Compiler Engineering Manager
Haochan Jiang, Compiler Engineer
Lili Cui, Compiler Engineer
Hongyu Wang, Compiler Engineering Manager
Lingling Kong, Compiler Engineer
Zhang Jun, Compiler Engineer
Xu Liwei, Compiler Engineer
Hui Lin, Compiler Engineer
A one line code change to the GNU Compiler Collection (GCC) for its generic x86 tuning is benefiting modern Intel and AMD processors.
Intel software engineer Lili Cui was quite worthwhile increasing the cost of the generic x86 tuning for the cost. On the basis of modern CPUs having decides
wrong
she
that's
by
updated
penalty
modern
time
if
is
guess
calculate
with
all
50
finally
threshold
stops
risky
branchless
instead
for
out
CPU
lot
work