From patchwork Thu Aug 4 08:09:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 73244 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1262685qga; Thu, 4 Aug 2016 01:10:26 -0700 (PDT) X-Received: by 10.98.7.200 with SMTP id 69mr123949545pfh.33.1470298226565; Thu, 04 Aug 2016 01:10:26 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s15si13459780pfs.58.2016.08.04.01.10.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 01:10:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-433156-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-433156-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-433156-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=WtMyw1BB0J/U2W+56 kqFtxS75q/fHTjBfYW6CHDxoQl5bKL6iPYXiwG3f0147n+w9xmInH1ddaTdJGPNQ 4fHcFV1WrqlbNvfPAIKnLsQ+UjJ1zk5VIPExZbCfrEeZu96A7ubSvZ7RLEEF/3O6 i/+1axnF1wxpSvJD6Ih952KuD4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=u5Zm+juwj2eMsuPIEX28dvJ Uaj0=; b=wYOFMG3ccJ0lZ/lnR+sZA4VMQC1Ozlge/iG6tgng2VY74O7orZEeJbz sHOrnwItcCfcp9Wf35lus5RLFfqLKR+OiunVwdennQ9HpoKroh8J/3eqO+99nHV9 8ukNrhi9skdOroRAiJkEKeNj4xwdof6LI2UD5a5P7iTAZnRHWwlA= Received: (qmail 78202 invoked by alias); 4 Aug 2016 08:10:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 78171 invoked by uid 89); 4 Aug 2016 08:10:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=Renamed, similarity, 7106 X-HELO: mail-pa0-f43.google.com Received: from mail-pa0-f43.google.com (HELO mail-pa0-f43.google.com) (209.85.220.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 04 Aug 2016 08:10:02 +0000 Received: by mail-pa0-f43.google.com with SMTP id ti13so2960222pac.0 for ; Thu, 04 Aug 2016 01:10:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=K5nNBdAxF8Ro4kN6quX24tojF+1Lri9jcLINmhx+KS4=; b=Nfs2HX/rDQYEO0a61ZYl/0UJnkBo3lLwMgiilTuk+XGNev4ZDsASdwCWmsqgcQFgpl C0z6otG7P4iAGHujfYquXmdqyyzVU/7TqI2CBq+9bztAIoB1P1Upyo2W9ObPJiXacFub GxNLg1SLx8tfUi/A1Ta21WIuOk4XXa7pwst7NJMLac32nQH0C5bCzeoS7UZO1dJOzBh/ S5W93mdB47+QskNelSzmwv6PrOrE3oT8to1CdaEAqT+NOMc3IvQVrzrUR/fon/RpRTOz DeBW/ukyPjGx00y7wwGkV5kp/mG4T21X2hlPQlyytlWF2nWKE5VC9NCLtjVJlC2wg85T IpqQ== X-Gm-Message-State: AEkooutx9uKoXP1nsYk6YeMXXdf6ormifYCeBde6NtTsjqw2IhUb3MFsaK0+XK+o59reoyff X-Received: by 10.66.161.195 with SMTP id xu3mr122838758pab.68.1470298200183; Thu, 04 Aug 2016 01:10:00 -0700 (PDT) Received: from [10.1.1.4] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.gmail.com with ESMTPSA id q1sm17959561pfd.48.2016.08.04.01.09.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 01:09:59 -0700 (PDT) Subject: Re: [LTO] Add wide_int streaming support To: Richard Biener References: Cc: "gcc-patches@gcc.gnu.org" , Jan Hubicka From: kugan Message-ID: Date: Thu, 4 Aug 2016 18:09:42 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes Hi Richard, Thanks for the review. On 04/08/16 17:26, Richard Biener wrote: > On Thu, Aug 4, 2016 at 6:12 AM, kugan wrote: >> Hi, >> >> During IPA-VRP implementation, I realized that we don't support streaming >> wide_int in LTO. Attached patch does this. Tested with IPA-VRP. Is this OK >> for trunk if bootstrap and regression testing is fine. > > Hmm, those functions belong to data-streamer-{in,out}.c and data-streamer.h > and should be named streamer_write_wide_int / streamer_read_wide_int. > > Note that we already have (non-exported) streamer_write_wi / streamer_read_wi > which operate on widest_ints. Those also reside in lto-streamer-{in,out}.c and > should be moved to data-streamer.h (and be renamed to > streamer_write_widest_int). I have now streamer_write_wide_int and streamer_write_widest_int. Similarly for reading. There is lot of similarity. I am not very familiar with wide_int so kept it that way. Is this OK now? Thanks, Kugan gcc/ChangeLog: 2016-08-04 Kugan Vivekanandarajah * data-streamer-in.c (streamer_read_wide_int): New. (streamer_read_widest_int): Renamed function. * data-streamer-out.c (streamer_write_wide_int): New (streamer_write_widest_int): Renamed function. * lto-streamer-in.c (streamer_read_wi): Renamed and moved to data-stream-in.c. (input_cfg): Call renamed function. * lto-streamer-out.c (streamer_write_wi): Renamed and moved to data-stream-out.c. (output_cfg): Call renamed function. * data-streamer.h: Add declarations. > > There is no need to add additional hooks. > > Can you do this please? > > Thanks, > Richard. > >> Thanks, >> Kugan >> >> gcc/ChangeLog: >> >> 2016-08-04 Kugan Vivekanandarajah >> >> * lto-streamer-in.c (lto_input_wide_int): New. >> * lto-streamer-out.c (lto_output_wide_int): Likewise. >> * lto-streamer.c (lto_streamer_hooks_init): Init write_wide_int and >> read_wide_int. >> * lto-streamer.h: Declare lto_input_wide_int and >> lto_output_wide_int. >> * streamer-hooks.h (struct streamer_hooks): Add write_wide_int and >> read_wide_int. >> (stream_write_wide_int): New macro. >> (stream_read_wide_int): Likewise. >> >From fb2561bcdaf656c464b98dad28db96fcdf74af17 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Thu, 4 Aug 2016 11:54:00 +1000 Subject: [PATCH 6/8] Add wide_int streaming support --- gcc/data-streamer-in.c | 31 +++++++++++++++++++++++++++++++ gcc/data-streamer-out.c | 27 +++++++++++++++++++++++++++ gcc/data-streamer.h | 4 ++++ gcc/lto-streamer-in.c | 21 +++------------------ gcc/lto-streamer-out.c | 20 +++----------------- 5 files changed, 68 insertions(+), 35 deletions(-) diff --git a/gcc/data-streamer-in.c b/gcc/data-streamer-in.c index 2625af6..8664a86 100644 --- a/gcc/data-streamer-in.c +++ b/gcc/data-streamer-in.c @@ -184,3 +184,34 @@ streamer_read_gcov_count (struct lto_input_block *ib) gcc_assert (ret >= 0); return ret; } + +/* Read the physical representation of a wide_int val from + input block IB. */ + +wide_int +streamer_read_wide_int (struct lto_input_block *ib) +{ + HOST_WIDE_INT a[WIDE_INT_MAX_ELTS]; + int i; + int prec = streamer_read_uhwi (ib); + int len = streamer_read_uhwi (ib); + for (i = 0; i < len; i++) + a[i] = streamer_read_hwi (ib); + return wide_int_storage::from_array (a, len, prec); +} + +/* Read the physical representation of a widest_int val from + input block IB. */ + +widest_int +streamer_read_widest_int (struct lto_input_block *ib) +{ + HOST_WIDE_INT a[WIDE_INT_MAX_ELTS]; + int i; + int prec ATTRIBUTE_UNUSED = streamer_read_uhwi (ib); + int len = streamer_read_uhwi (ib); + for (i = 0; i < len; i++) + a[i] = streamer_read_hwi (ib); + return widest_int::from_array (a, len); +} + diff --git a/gcc/data-streamer-out.c b/gcc/data-streamer-out.c index e476530..3dd423b 100644 --- a/gcc/data-streamer-out.c +++ b/gcc/data-streamer-out.c @@ -375,3 +375,30 @@ streamer_write_data_stream (struct lto_output_stream *obs, const void *data, } } +/* Emit the physical representation of wide_int VAL to output block OB. */ + +void +streamer_write_wide_int (struct output_block *ob, const wide_int &val) +{ + int len = val.get_len (); + + streamer_write_uhwi (ob, val.get_precision ()); + streamer_write_uhwi (ob, len); + for (int i = 0; i < len; i++) + streamer_write_hwi (ob, val.elt (i)); +} + +/* Emit the physical representation of widest_int W to output block OB. */ + +void +streamer_write_widest_int (struct output_block *ob, + const widest_int &w) +{ + int len = w.get_len (); + + streamer_write_uhwi (ob, w.get_precision ()); + streamer_write_uhwi (ob, len); + for (int i = 0; i < len; i++) + streamer_write_hwi (ob, w.elt (i)); +} + diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h index 0048f66..ff479a6 100644 --- a/gcc/data-streamer.h +++ b/gcc/data-streamer.h @@ -69,6 +69,8 @@ void streamer_write_hwi_stream (struct lto_output_stream *, HOST_WIDE_INT); void streamer_write_gcov_count_stream (struct lto_output_stream *, gcov_type); void streamer_write_data_stream (struct lto_output_stream *, const void *, size_t); +void streamer_write_wide_int (struct output_block *, const wide_int &); +void streamer_write_widest_int (struct output_block *, const widest_int &); /* In data-streamer-in.c */ const char *streamer_read_string (struct data_in *, struct lto_input_block *); @@ -81,6 +83,8 @@ const char *bp_unpack_string (struct data_in *, struct bitpack_d *); unsigned HOST_WIDE_INT streamer_read_uhwi (struct lto_input_block *); HOST_WIDE_INT streamer_read_hwi (struct lto_input_block *); gcov_type streamer_read_gcov_count (struct lto_input_block *); +wide_int streamer_read_wide_int (struct lto_input_block *); +widest_int streamer_read_widest_int (struct lto_input_block *); /* Returns a new bit-packing context for bit-packing into S. */ static inline struct bitpack_d diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 1d56d21..5075b56 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -710,21 +710,6 @@ make_new_block (struct function *fn, unsigned int index) } -/* Read a wide-int. */ - -static widest_int -streamer_read_wi (struct lto_input_block *ib) -{ - HOST_WIDE_INT a[WIDE_INT_MAX_ELTS]; - int i; - int prec ATTRIBUTE_UNUSED = streamer_read_uhwi (ib); - int len = streamer_read_uhwi (ib); - for (i = 0; i < len; i++) - a[i] = streamer_read_hwi (ib); - return widest_int::from_array (a, len); -} - - /* Read the CFG for function FN from input block IB. */ static void @@ -834,13 +819,13 @@ input_cfg (struct lto_input_block *ib, struct data_in *data_in, loop->estimate_state = streamer_read_enum (ib, loop_estimation, EST_LAST); loop->any_upper_bound = streamer_read_hwi (ib); if (loop->any_upper_bound) - loop->nb_iterations_upper_bound = streamer_read_wi (ib); + loop->nb_iterations_upper_bound = streamer_read_widest_int (ib); loop->any_likely_upper_bound = streamer_read_hwi (ib); if (loop->any_likely_upper_bound) - loop->nb_iterations_likely_upper_bound = streamer_read_wi (ib); + loop->nb_iterations_likely_upper_bound = streamer_read_widest_int (ib); loop->any_estimate = streamer_read_hwi (ib); if (loop->any_estimate) - loop->nb_iterations_estimate = streamer_read_wi (ib); + loop->nb_iterations_estimate = streamer_read_widest_int (ib); /* Read OMP SIMD related info. */ loop->safelen = streamer_read_hwi (ib); diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index aa6b589..bc45721 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -1828,20 +1828,6 @@ output_ssa_names (struct output_block *ob, struct function *fn) } -/* Output a wide-int. */ - -static void -streamer_write_wi (struct output_block *ob, - const widest_int &w) -{ - int len = w.get_len (); - - streamer_write_uhwi (ob, w.get_precision ()); - streamer_write_uhwi (ob, len); - for (int i = 0; i < len; i++) - streamer_write_hwi (ob, w.elt (i)); -} - /* Output the cfg. */ @@ -1915,13 +1901,13 @@ output_cfg (struct output_block *ob, struct function *fn) loop_estimation, EST_LAST, loop->estimate_state); streamer_write_hwi (ob, loop->any_upper_bound); if (loop->any_upper_bound) - streamer_write_wi (ob, loop->nb_iterations_upper_bound); + streamer_write_widest_int (ob, loop->nb_iterations_upper_bound); streamer_write_hwi (ob, loop->any_likely_upper_bound); if (loop->any_likely_upper_bound) - streamer_write_wi (ob, loop->nb_iterations_likely_upper_bound); + streamer_write_widest_int (ob, loop->nb_iterations_likely_upper_bound); streamer_write_hwi (ob, loop->any_estimate); if (loop->any_estimate) - streamer_write_wi (ob, loop->nb_iterations_estimate); + streamer_write_widest_int (ob, loop->nb_iterations_estimate); /* Write OMP SIMD related info. */ streamer_write_hwi (ob, loop->safelen); -- 1.9.1