]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
options: Clarify 'Init' option property usage for streaming optimization
authorThomas Schwinge <thomas@codesourcery.com>
Thu, 31 Mar 2022 10:06:29 +0000 (12:06 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Thu, 27 Oct 2022 08:41:41 +0000 (10:41 +0200)
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

index 49065ced0b3d977000db0ec60d274da6ecccd305..2b8557f41ada1fb603e910c505ca8bfa84da2118 100644 (file)
@@ -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] ";";
                }
        }
 }