From patchwork Thu Feb 6 18:56:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Stump X-Patchwork-Id: 317521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 961532C0081 for ; Fri, 7 Feb 2014 05:56:24 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; q=dns; s= default; b=IfqIUwEJGVxWdSSxQI3dntOhm9mX0/nJHhAVyyLVHrdfVrRUSaSL+ SlwaSET5FFDIYBaaT0mdErl8l1CDsj1tEYfG62+namtLLdOhAr9TbiKM/C9sLO5f EJceBvd4oPozNGvJY01e+uemKfqpzID+GCOo4WQflKOU4t1gV2K2MQ= 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 :content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=default; bh=eLSYUkcMfaKkS6lQkaZ02w2SwGQ=; b=sm4VKbGCPwn5YM7cj+SuYxsfCTeM 4ZB8rYwIFFVy3jsjEYv+UPUHm84qUgd+GV7wQ4zPVAeOIYqqOs0OzZpkJWHW6qqB qVjtqcXqyxYoQ12RiTSoxcXO2erCs4EUPr66FCGH6OSNP1zAYO09kvzYBCvyizMw 2J6iRh3MaZtjP3Y= Received: (qmail 5620 invoked by alias); 6 Feb 2014 18:56:18 -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 5611 invoked by uid 89); 6 Feb 2014 18:56:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: qmta09.emeryville.ca.mail.comcast.net Received: from qmta09.emeryville.ca.mail.comcast.net (HELO qmta09.emeryville.ca.mail.comcast.net) (76.96.30.96) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Feb 2014 18:56:17 +0000 Received: from omta07.emeryville.ca.mail.comcast.net ([76.96.30.59]) by qmta09.emeryville.ca.mail.comcast.net with comcast id P6vk1n0041GXsucA96wFVP; Thu, 06 Feb 2014 18:56:15 +0000 Received: from [10.0.0.2] ([24.4.193.8]) by omta07.emeryville.ca.mail.comcast.net with comcast id P6wE1n00D0BKwT48U6wEaF; Thu, 06 Feb 2014 18:56:15 +0000 Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Subject: Re: wide-int, lto From: Mike Stump In-Reply-To: Date: Thu, 6 Feb 2014 10:56:13 -0800 Cc: "gcc-patches@gcc.gnu.org Patches" , Diego Novillo , Kenneth Zadeck Message-Id: References: <47EC5218-729C-43C9-A423-2D9056C80039@comcast.net> To: Richard Biener X-IsSubscribed: yes On Nov 25, 2013, at 3:09 AM, Richard Biener wrote: > please add streamer_read/write_wi () helpers to data-streamer* > > replicating the above loop N times is too ugly. Agreed. Below is the patch to collapse the code. Thanks. diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c index 08eba48..3e02840 100644 --- a/gcc/lto-streamer-in.c +++ b/gcc/lto-streamer-in.c @@ -617,6 +617,21 @@ 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 @@ -726,28 +741,10 @@ 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) - { - 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); - - loop->nb_iterations_upper_bound = widest_int::from_array (a, len); - } + loop->nb_iterations_upper_bound = streamer_read_wi (ib); loop->any_estimate = streamer_read_hwi (ib); if (loop->any_estimate) - { - 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); - - loop->nb_iterations_estimate = widest_int::from_array (a, len); - } + loop->nb_iterations_estimate = streamer_read_wi (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 de19235..60acb42 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -1622,6 +1622,21 @@ 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. */ static void @@ -1694,26 +1709,10 @@ 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) - { - int len = loop->nb_iterations_upper_bound.get_len (); - int i; - - streamer_write_uhwi (ob, loop->nb_iterations_upper_bound.get_precision ()); - streamer_write_uhwi (ob, len); - for (i = 0; i < len; i++) - streamer_write_hwi (ob, loop->nb_iterations_upper_bound.elt (i)); - } + streamer_write_wi (ob, loop->nb_iterations_upper_bound); streamer_write_hwi (ob, loop->any_estimate); if (loop->any_estimate) - { - int len = loop->nb_iterations_estimate.get_len (); - int i; - - streamer_write_uhwi (ob, loop->nb_iterations_estimate.get_precision ()); - streamer_write_uhwi (ob, len); - for (i = 0; i < len; i++) - streamer_write_hwi (ob, loop->nb_iterations_estimate.elt (i)); - } + streamer_write_wi (ob, loop->nb_iterations_estimate); /* Write OMP SIMD related info. */ streamer_write_hwi (ob, loop->safelen);