From c7968fa44b1073dfa7da3a11470a9e76b6faafaf Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 31 Mar 2022 12:06:29 +0200
Subject: [PATCH] options: Clarify 'Init' option property usage for streaming
optimization
This clarifies commit 95db7e9afe57ca1c269d46baa2accced004e5c74
"options, lto: Optimize streaming of optimization nodes".
No functional change; no change in generated files.
gcc/
* optc-save-gen.awk: Clarify 'Init' option property usage for
streaming optimization.
---
gcc/optc-save-gen.awk | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
@@ -1292,7 +1292,22 @@ for (i = 0; i < n_opts; i++) {
var_opt_val_type[n_opt_val] = otype;
var_opt_val[n_opt_val] = "x_" name;
var_opt_hash[n_opt_val] = flag_set_p("Optimization", flags[i]);
- var_opt_init[n_opt_val] = opt_args("Init", flags[i]);
+
+ # If applicable, optimize streaming for the common case that
+ # the current value is unchanged from the 'Init' value:
+ # XOR-encode it so that we stream value zero.
+ # Not handling non-parameters as those really generally don't
+ # have large initializers.
+ # Not handling enums as we don't know if '(enum ...) 10' is
+ # even valid (see synthesized 'if' conditionals below).
+ if (flag_set_p("Param", flags[i]) \
+ && !(otype ~ "^enum ")) {
+ # Those without 'Init' are zero-initialized and thus
+ # already encoded ideally.
+ init = opt_args("Init", flags[i])
+ var_opt_optimize_init[n_opt_val] = init;
+ }
+
n_opt_val++;
}
}
@@ -1370,9 +1385,10 @@ for (i = 0; i < n_opt_val; i++) {
} else {
sgn = "int";
}
- if (name ~ "^x_param" && !(otype ~ "^enum ") && var_opt_init[i]) {
- print " if (" var_opt_init[i] " > (" var_opt_val_type[i] ") 10)";
- print " bp_pack_var_len_" sgn " (bp, ptr->" name" ^ " var_opt_init[i] ");";
+ # If applicable, encode the streamed value.
+ if (var_opt_optimize_init[i]) {
+ print " if (" var_opt_optimize_init[i] " > (" var_opt_val_type[i] ") 10)";
+ print " bp_pack_var_len_" sgn " (bp, ptr->" name" ^ " var_opt_optimize_init[i] ");";
print " else";
print " bp_pack_var_len_" sgn " (bp, ptr->" name");";
} else {
@@ -1406,9 +1422,10 @@ for (i = 0; i < n_opt_val; i++) {
sgn = "int";
}
print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_var_len_" sgn " (bp);";
- if (name ~ "^x_param" && !(otype ~ "^enum ") && var_opt_init[i]) {
- print " if (" var_opt_init[i] " > (" var_opt_val_type[i] ") 10)";
- print " ptr->" name" ^= " var_opt_init[i] ";";
+ # If applicable, decode the streamed value.
+ if (var_opt_optimize_init[i]) {
+ print " if (" var_opt_optimize_init[i] " > (" var_opt_val_type[i] ") 10)";
+ print " ptr->" name" ^= " var_opt_optimize_init[i] ";";
}
}
}
--
2.35.1