From patchwork Thu Jun 6 12:51:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 249402 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id F26C32C009D for ; Thu, 6 Jun 2013 22:52:10 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=M1gz407VWuwpvTYJjBt3yYwee/FvP1KqrzM1rEvsZQ/iUmXGDtnVz dt6N0dKRrl32N6ZB+0J22ryVCe0h6p1N8d6hvrqtOkgT6Mw7pOkCo6bMPc7uWG9w QJVDR9TbxStoW3Rqcf5PHlI0bhCmg8xEEOSyge4AyLKUoTtXcjW84o= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=TBhITLrS9ajs9SF8YN6tkIoLUdY=; b=VVSHWdLJAEGRWutzuRjX qx1+GLwuGfDqkAnzZpiMwE2wFOVU3tOXMxGbmazErKWUzxhs3n+WgP+uRv0L2drq r0uoCgP/rjM0zGQt9vys3rlwXzaChSiAxsUSVdxjy9lciFNQi8ipa3JjcCK2lqJB ce1Lcg4VPUubV+rb38nvjdo= Received: (qmail 23979 invoked by alias); 6 Jun 2013 12:52:04 -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 23958 invoked by uid 89); 6 Jun 2013 12:52:01 -0000 X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 06 Jun 2013 12:52:00 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5A1C5A566A for ; Thu, 6 Jun 2013 14:51:58 +0200 (CEST) Date: Thu, 6 Jun 2013 14:51:58 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Shrink LTO bytecode Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 This shrinks LTO_tree_pickle_reference and all LTO headers by using uhwi streaming instead of fixed-size streaming for streamer_write_hwi_in_range/streamer_read_hwi_in_range. LTO_tree_pickle_reference are the most issued records so it's worth optimizing its placement so it can use a 1 byte record. LTO bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2013-06-06 Richard Biener * lto-streamer.h (enum LTO_tags): Move LTO_tree_pickle_reference after LTO_null. (lto_tag_is_tree_code_p): Adjust. (lto_tag_is_gimple_code_p): Likewise. (lto_gimple_code_to_tag): Likewise. (lto_tag_to_gimple_code): Likewise. (lto_tree_code_to_tag): Likewise. (lto_tag_to_tree_code): Likewise. * data-streamer.h (streamer_write_hwi_in_range): Use uhwi streaming to stream the normalized range. (streamer_read_hwi_in_range): Likewise. Index: gcc/lto-streamer.h =================================================================== --- gcc/lto-streamer.h (revision 199720) +++ gcc/lto-streamer.h (working copy) @@ -155,6 +155,9 @@ enum LTO_tags { LTO_null = 0, + /* Special for streamer. Reference to previously-streamed node. */ + LTO_tree_pickle_reference, + /* Reserve enough entries to fit all the tree and gimple codes handled by the streamer. This guarantees that: @@ -196,9 +199,6 @@ enum LTO_tags /* EH try/catch node. */ LTO_eh_catch, - /* Special for global streamer. Reference to previously-streamed node. */ - LTO_tree_pickle_reference, - /* References to indexable tree nodes. These objects are stored in tables that are written separately from the function bodies that reference them. This way they can be instantiated even when the @@ -921,7 +921,7 @@ extern vec lto_f static inline bool lto_tag_is_tree_code_p (enum LTO_tags tag) { - return tag > LTO_null && (unsigned) tag <= MAX_TREE_CODES; + return tag > LTO_tree_pickle_reference && (unsigned) tag <= MAX_TREE_CODES; } @@ -929,8 +929,8 @@ lto_tag_is_tree_code_p (enum LTO_tags ta static inline bool lto_tag_is_gimple_code_p (enum LTO_tags tag) { - return (unsigned) tag >= NUM_TREE_CODES + 1 - && (unsigned) tag < 1 + NUM_TREE_CODES + LAST_AND_UNUSED_GIMPLE_CODE; + return (unsigned) tag >= NUM_TREE_CODES + 2 + && (unsigned) tag < 2 + NUM_TREE_CODES + LAST_AND_UNUSED_GIMPLE_CODE; } @@ -939,7 +939,7 @@ lto_tag_is_gimple_code_p (enum LTO_tags static inline enum LTO_tags lto_gimple_code_to_tag (enum gimple_code code) { - return (enum LTO_tags) ((unsigned) code + NUM_TREE_CODES + 1); + return (enum LTO_tags) ((unsigned) code + NUM_TREE_CODES + 2); } @@ -949,7 +949,7 @@ static inline enum gimple_code lto_tag_to_gimple_code (enum LTO_tags tag) { gcc_assert (lto_tag_is_gimple_code_p (tag)); - return (enum gimple_code) ((unsigned) tag - NUM_TREE_CODES - 1); + return (enum gimple_code) ((unsigned) tag - NUM_TREE_CODES - 2); } @@ -958,7 +958,7 @@ lto_tag_to_gimple_code (enum LTO_tags ta static inline enum LTO_tags lto_tree_code_to_tag (enum tree_code code) { - return (enum LTO_tags) ((unsigned) code + 1); + return (enum LTO_tags) ((unsigned) code + 2); } @@ -968,7 +968,7 @@ static inline enum tree_code lto_tag_to_tree_code (enum LTO_tags tag) { gcc_assert (lto_tag_is_tree_code_p (tag)); - return (enum tree_code) ((unsigned) tag - 1); + return (enum tree_code) ((unsigned) tag - 2); } /* Check that tag ACTUAL == EXPECTED. */ Index: gcc/data-streamer.h =================================================================== --- gcc/data-streamer.h (revision 199720) +++ gcc/data-streamer.h (working copy) @@ -216,13 +216,7 @@ streamer_write_hwi_in_range (struct lto_ && range < 0x7fffffff); val -= min; - streamer_write_char_stream (obs, val & 255); - if (range >= 0xff) - streamer_write_char_stream (obs, (val >> 8) & 255); - if (range >= 0xffff) - streamer_write_char_stream (obs, (val >> 16) & 255); - if (range >= 0xffffff) - streamer_write_char_stream (obs, (val >> 24) & 255); + streamer_write_uhwi_stream (obs, (unsigned HOST_WIDE_INT) val); } /* Input VAL into OBS and verify it is in range MIN...MAX that is supposed @@ -235,17 +229,11 @@ streamer_read_hwi_in_range (struct lto_i HOST_WIDE_INT max) { HOST_WIDE_INT range = max - min; - HOST_WIDE_INT val = streamer_read_uchar (ib); + unsigned HOST_WIDE_INT uval = streamer_read_uhwi (ib); gcc_checking_assert (range > 0 && range < 0x7fffffff); - if (range >= 0xff) - val |= ((HOST_WIDE_INT)streamer_read_uchar (ib)) << 8; - if (range >= 0xffff) - val |= ((HOST_WIDE_INT)streamer_read_uchar (ib)) << 16; - if (range >= 0xffffff) - val |= ((HOST_WIDE_INT)streamer_read_uchar (ib)) << 24; - val += min; + HOST_WIDE_INT val = (HOST_WIDE_INT) (uval + (unsigned HOST_WIDE_INT) min); if (val < min || val > max) lto_value_range_error (purpose, val, min, max); return val;