public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3524] options: Clarify 'Init' option property usage for streaming optimization
@ 2022-10-27  8:42 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-10-27  8:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9119431bc1563217c7c770035b0456d1e2bc596d

commit r13-3524-g9119431bc1563217c7c770035b0456d1e2bc596d
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Thu Mar 31 12:06:29 2022 +0200

    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.

Diff:
---
 gcc/optc-save-gen.awk | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 49065ced0b3..2b8557f41ad 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1291,7 +1291,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++;
 	}
 }
@@ -1369,9 +1384,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 {
@@ -1405,9 +1421,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] ";";
 		}
 	}
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-27  8:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27  8:42 [gcc r13-3524] options: Clarify 'Init' option property usage for streaming optimization Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).