From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 8BB563959CBE for ; Mon, 14 Sep 2020 06:39:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8BB563959CBE Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rguenther@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1B970AF0B; Mon, 14 Sep 2020 06:39:38 +0000 (UTC) Date: Mon, 14 Sep 2020 08:39:22 +0200 (CEST) From: Richard Biener To: Jakub Jelinek cc: "Joseph S. Myers" , Jan Hubicka , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] options, lto: Optimize streaming of optimization nodes In-Reply-To: <20200913083327.GG21814@tucnak> Message-ID: References: <20200913083327.GG21814@tucnak> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2020 06:39:25 -0000 On Sun, 13 Sep 2020, Jakub Jelinek wrote: > 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? Hmm, in principle the LTO bytecode format should be not dependent on the host, while it probably doesn't work right now to move 32bit host to 64bit host targeting the same target bytecode files the following makes explicit use of HOST_* and that might have been the reason we're using 64bit encodings for everything. Note using 64bits isn't too bad in practice since we uleb encode the bitpack words and outputing 64bits basically ensures we're outputting a stream of uleb encoded uint64_t. Richard. > 2020-09-13 Jakub Jelinek > > * 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(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(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(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(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 > > -- Richard Biener SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)