From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>,
"Joseph S. Myers" <joseph@codesourcery.com>,
Jan Hubicka <jh@suse.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] options, lto: Optimize streaming of optimization nodes
Date: Sun, 13 Sep 2020 10:33:27 +0200 [thread overview]
Message-ID: <20200913083327.GG21814@tucnak> (raw)
Hi!
When working on the previous patch, I've noticed that all cl_optimization
fields appart from strings are streamed with bp_pack_value (..., 64); so we
waste quite a lot of space, given that many of the options are just booleans
or char options and there are 450-ish of them.
Fixed by streaming the number of bits the corresponding fields have.
While for char fields we have also range information, except for 3
it is either -128, 127 or 0, 255, so it didn't seem worth it to bother
with using range-ish packing.
Bootstrapped/regtested on x86_64-linux, i686-linux, armv7hl-linux-gnueabi,
aarch64-linux, powerpc64le-linux and lto bootstrapped on x86_64-linux, ok
for trunk?
2020-09-13 Jakub Jelinek <jakub@redhat.com>
* optc-save-gen.awk: In cl_optimization_stream_out and
cl_optimization_stream_in, stream int, enum, short and char
variables with corresponding HOST_BITS_PER_* rather than
hardcoded 64.
--- gcc/optc-save-gen.awk.jj 2020-09-11 17:38:31.524230167 +0200
+++ gcc/optc-save-gen.awk 2020-09-11 22:12:59.948580827 +0200
@@ -1252,13 +1252,23 @@ print "cl_optimization_stream_out (struc
print " struct bitpack_d *bp,";
print " struct cl_optimization *ptr)";
print "{";
-for (i = 0; i < n_opt_val; i++) {
- name = var_opt_val[i]
- otype = var_opt_val_type[i];
- if (otype ~ "^const char \\**$")
- print " bp_pack_string (ob, bp, ptr->" name", true);";
- else
- print " bp_pack_value (bp, ptr->" name", 64);";
+for (i = 0; i < n_opt_other; i++) {
+ print " bp_pack_value (bp, ptr->x_" var_opt_other[i] ", HOST_BITS_PER_WIDE_INT);";
+}
+for (i = 0; i < n_opt_int; i++) {
+ print " bp_pack_value (bp, static_cast<unsigned int>(ptr->x_" var_opt_int[i] "), HOST_BITS_PER_INT);";
+}
+for (i = 0; i < n_opt_enum; i++) {
+ print " bp_pack_value (bp, static_cast<unsigned int>(ptr->x_" var_opt_enum[i] "), HOST_BITS_PER_INT);";
+}
+for (i = 0; i < n_opt_short; i++) {
+ print " bp_pack_value (bp, static_cast<unsigned short>(ptr->x_" var_opt_short[i] "), HOST_BITS_PER_SHORT);";
+}
+for (i = 0; i < n_opt_char; i++) {
+ print " bp_pack_value (bp, static_cast<unsigned char>(ptr->x_" var_opt_char[i] "), HOST_BITS_PER_CHAR);";
+}
+for (i = 0; i < n_opt_string; i++) {
+ print " bp_pack_string (ob, bp, ptr->x_" var_opt_string[i] ", true);";
}
print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
print " bp_pack_value (bp, ptr->explicit_mask[i], 64);";
@@ -1271,17 +1281,26 @@ print "cl_optimization_stream_in (struct
print " struct bitpack_d *bp ATTRIBUTE_UNUSED,";
print " struct cl_optimization *ptr ATTRIBUTE_UNUSED)";
print "{";
-for (i = 0; i < n_opt_val; i++) {
- name = var_opt_val[i]
- otype = var_opt_val_type[i];
- if (otype ~ "^const char \\**$")
- {
- print " ptr->" name" = bp_unpack_string (data_in, bp);";
- print " if (ptr->" name")";
- print " ptr->" name" = xstrdup (ptr->" name");";
- }
- else
- print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_value (bp, 64);";
+for (i = 0; i < n_opt_other; i++) {
+ print " ptr->x_" var_opt_other[i] " = bp_unpack_value (bp, HOST_BITS_PER_WIDE_INT);";
+}
+for (i = 0; i < n_opt_int; i++) {
+ print " ptr->x_" var_opt_int[i] " = bp_unpack_value (bp, HOST_BITS_PER_INT);";
+}
+for (i = 0; i < n_opt_enum; i++) {
+ print " ptr->x_" var_opt_enum[i] " = static_cast<" var_opt_enum_type[i] ">(bp_unpack_value (bp, HOST_BITS_PER_INT));";
+}
+for (i = 0; i < n_opt_short; i++) {
+ print " ptr->x_" var_opt_short[i] " = bp_unpack_value (bp, HOST_BITS_PER_SHORT);";
+}
+for (i = 0; i < n_opt_char; i++) {
+ print " ptr->x_" var_opt_char[i] " = bp_unpack_value (bp, HOST_BITS_PER_CHAR);";
+}
+for (i = 0; i < n_opt_string; i++) {
+ name = var_opt_string[i];
+ print " ptr->x_" name" = bp_unpack_string (data_in, bp);";
+ print " if (ptr->x_" name")";
+ print " ptr->x_" name" = xstrdup (ptr->x_" name");";
}
print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)";
print " ptr->explicit_mask[i] = bp_unpack_value (bp, 64);";
Jakub
next reply other threads:[~2020-09-13 8:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-13 8:33 Jakub Jelinek [this message]
2020-09-14 6:39 ` Richard Biener
2020-09-14 7:00 ` Jakub Jelinek
2020-09-14 7:31 ` Richard Biener
2020-09-14 8:48 ` Jakub Jelinek
2020-09-14 9:02 ` Jan Hubicka
2020-09-14 9:47 ` Jakub Jelinek
2020-10-05 9:21 ` Patch ping (Re: [PATCH] options, lto: Optimize streaming of optimization nodes) Jakub Jelinek
2020-11-18 9:36 ` [PATCH] options, lto: Optimize streaming of optimization nodes Jakub Jelinek
2020-11-18 19:06 ` Joseph Myers
2022-03-31 13:22 ` options: Clarify 'Init' option property usage for streaming optimization (was: [PATCH] options, lto: Optimize streaming of optimization nodes) Thomas Schwinge
2022-10-26 13:46 ` [PING] " Thomas Schwinge
2022-10-26 18:21 ` Joseph Myers
2020-09-14 9:23 ` [PATCH] options, lto: Optimize streaming of optimization nodes Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200913083327.GG21814@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jh@suse.cz \
--cc=joseph@codesourcery.com \
--cc=rguenther@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).