From patchwork Sun Nov 17 10:29:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 291817 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 109192C00CA for ; Sun, 17 Nov 2013 21:29:56 +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:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=Jj/GNkvmzPg/GJgO3IXcuDb+nRCCBQoeDVLtOQxK1CMWSkkttf NENJ0YYa+iQNdMvqkOLtXVzES6QE/9gUfFrb0n9WmrhWSM86u90mAoPyK7U8urBG dpVuu+EXb/tcYoYrpS+D9hJJK4NTjc75LEnYfA2Ch3b8wHis1TlWvxPMM= 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:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=VV2bpiHJBV8EWNDKxUwE/sPhmwU=; b=ul+GoeCH15N07i7Q/48G 6S4MD/1rZk7tLKo5yiBmKTj66wDeR7Fcw9Q0PvR0l7wea3QnlWlWJ+RaN9tcjouM BEA9PIVmSkB91+otyVz8wocNzyJgg92s4c2YfibM9Uzhzxz8By8y3BZdNpE8U1AI spQ3C10//ksaWWmJsCbiVnU= Received: (qmail 13141 invoked by alias); 17 Nov 2013 10:29:45 -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 13132 invoked by uid 89); 17 Nov 2013 10:29:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-wi0-f182.google.com Received: from Unknown (HELO mail-wi0-f182.google.com) (209.85.212.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 17 Nov 2013 10:29:42 +0000 Received: by mail-wi0-f182.google.com with SMTP id en1so818641wid.9 for ; Sun, 17 Nov 2013 02:29:33 -0800 (PST) X-Received: by 10.180.198.79 with SMTP id ja15mr12869967wic.36.1384684173571; Sun, 17 Nov 2013 02:29:33 -0800 (PST) Received: from localhost ([2.28.235.51]) by mx.google.com with ESMTPSA id hv5sm12955075wib.2.2013.11.17.02.29.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Nov 2013 02:29:32 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, zadeck@naturalbridge.com, mikestump@comcast.net, rdsandiford@googlemail.com Cc: zadeck@naturalbridge.com, mikestump@comcast.net Subject: [wide-int] Remove tree_fits_hwi_p and tree_to_hwi Date: Sun, 17 Nov 2013 10:29:32 +0000 Message-ID: <87r4afqq2b.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 AIUI the two-argument tree_fits_hwi_p and tree_to_hwi were replacements for host_integerp and tree_low_cst with variable "pos" arguments. I removed those uses from trunk this week, and Mike's merge has brought that into branch. The only remaining use is in a branch-local change to the way that match_case_to_enum_1 prints constants. The old code was: /* ??? Not working too hard to print the double-word value. Should perhaps be done with %lwd in the diagnostic routines? */ if (TREE_INT_CST_HIGH (key) == 0) snprintf (buf, sizeof (buf), HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (key)); else if (!TYPE_UNSIGNED (type) && TREE_INT_CST_HIGH (key) == -1 && TREE_INT_CST_LOW (key) != 0) snprintf (buf, sizeof (buf), "-" HOST_WIDE_INT_PRINT_UNSIGNED, -TREE_INT_CST_LOW (key)); else snprintf (buf, sizeof (buf), HOST_WIDE_INT_PRINT_DOUBLE_HEX, (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (key), (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (key)); The first arm prints KEY as an unsigned HWI if the "infinite precision" value of KEY fits in an unsigned HWI (regardless of whether the type is signed or not, e.g. it could be a signed 128-bit type with a value that happens to fit in an unsigned 64-bit HWI). The second prints it as a negative HWI if KEY is negative and fits. The third arm is a hex fallback. But on branch we only print KEYs with signed types as decimal if they fit in signed HWIs, which is different from the first arm on trunk. This patch restores the trunk choices and gets rid of the then-unused functions. Also, the single-argument tree_fits_hwi_p was used only in one place, sdbout.c. On trunk it's a "host_integerp (..., 0)" call, so that translates to tree_fits_shwi_p on branch. Tested on x86_64-linux-gnu. OK to install? Thanks, Richard Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c 2013-11-16 22:21:20.716272495 +0000 +++ gcc/c-family/c-common.c 2013-11-16 22:36:56.575137937 +0000 @@ -6056,8 +6056,10 @@ match_case_to_enum_1 (tree key, tree typ { char buf[WIDE_INT_PRINT_BUFFER_SIZE]; - if (tree_fits_hwi_p (key, TYPE_SIGN (type))) - print_dec (key, buf, TYPE_SIGN (type)); + if (tree_fits_uhwi_p (key)) + print_dec (key, buf, UNSIGNED); + else if (tree_fits_shwi_p (key)) + print_dec (key, buf, SIGNED); else print_hex (key, buf); Index: gcc/doc/generic.texi =================================================================== --- gcc/doc/generic.texi 2013-11-16 22:21:23.034289829 +0000 +++ gcc/doc/generic.texi 2013-11-16 22:40:47.479832766 +0000 @@ -1024,10 +1024,8 @@ As this example indicates, the operands @tindex INTEGER_CST @tindex tree_fits_uhwi_p @tindex tree_fits_shwi_p -@tindex tree_fits_hwi_p @tindex tree_to_uhwi @tindex tree_to_shwi -@tindex tree_to_hwi @tindex REAL_CST @tindex FIXED_CST @tindex COMPLEX_CST @@ -1050,16 +1048,11 @@ represented in an array of HOST_WIDE_INT in the array to represent the value without taking extra elements for redundant 0s or -1. -The functions @code{tree_fits_uhwi_p}, @code{tree_fits_shwi_p}, and -@code{tree_fits_hwi_p} can be used to tell if the value is small -enough to fit in a HOST_WIDE_INT, as either a signed value, an unsiged -value or a value whose sign is given as a parameter. The value can -then be extracted using the @code{tree_to_uhwi}, @code{tree_to_shwi}, -or @code{tree_to_hwi}. The @code{tree_to_hwi} comes in both checked -and unchecked flavors. However, when the value is used in a context -where it may represent a value that is larger than can be represented -in HOST_BITS_PER_WIDE_INT bits, the wide_int class should be used to -manipulate the constant. +The functions @code{tree_fits_shwi_p} and @code{tree_fits_uhwi_p} +can be used to tell if the value is small enough to fit in a +signed HOST_WIDE_INT or an unsigned HOST_WIDE_INT respectively. +The value can then be extracted using @code{tree_to_shwi} and +@code{tree_to_uhwi}. @item REAL_CST Index: gcc/sdbout.c =================================================================== --- gcc/sdbout.c 2013-10-22 10:15:14.050507121 +0100 +++ gcc/sdbout.c 2013-11-16 22:37:51.168539468 +0000 @@ -1152,7 +1152,7 @@ sdbout_one_type (tree type) if (TREE_CODE (value) == CONST_DECL) value = DECL_INITIAL (value); - if (tree_fits_hwi_p (value)) + if (tree_fits_shwi_p (value)) { PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem))); PUT_SDB_INT_VAL (tree_to_shwi (value)); Index: gcc/tree.h =================================================================== --- gcc/tree.h 2013-11-16 22:21:25.473308066 +0000 +++ gcc/tree.h 2013-11-16 22:42:05.148400937 +0000 @@ -3235,37 +3235,6 @@ tree_fits_shwi_p (const_tree cst) return false; } -/* Return true if T is an INTEGER_CST that can be manipulated - efficiently on the host. If SIGN is SIGNED, the value can be - represented in a single HOST_WIDE_INT. If SIGN is UNSIGNED, the - value must be non-negative and can be represented in a single - unsigned HOST_WIDE_INT. */ - -static inline bool -tree_fits_hwi_p (const_tree cst, signop sign) -{ - return sign ? tree_fits_uhwi_p (cst) : tree_fits_shwi_p (cst); -} - -/* Return true if T is an INTEGER_CST that can be manipulated - efficiently on the host. If the sign of CST is SIGNED, the value - can be represented in a single HOST_WIDE_INT. If the sign of CST - is UNSIGNED, the value must be non-negative and can be represented - in a single unsigned HOST_WIDE_INT. */ - -static inline bool -tree_fits_hwi_p (const_tree cst) -{ - if (cst == NULL_TREE) - return false; - - if (TREE_CODE (cst) != INTEGER_CST) - return false; - - return TYPE_UNSIGNED (TREE_TYPE (cst)) - ? tree_fits_uhwi_p (cst) : tree_fits_shwi_p (cst); -} - /* Return the unsigned HOST_WIDE_INT least significant bits of CST. If checking is enabled, this ices if the value does not fit. */ @@ -3298,19 +3267,6 @@ tree_to_hwi (const_tree cst) return TREE_INT_CST_ELT (cst, 0); } -/* Return the HOST_WIDE_INT least significant bits of CST. The sign - of the checking is based on SIGNOP. */ - -static inline HOST_WIDE_INT -tree_to_hwi (const_tree cst, signop sgn) -{ - if (sgn == SIGNED) - return tree_to_shwi (cst); - else - return tree_to_uhwi (cst); -} - - /* Compute the number of operands in an expression node NODE. For tcc_vl_exp nodes like CALL_EXPRs, this is stored in the node itself, otherwise it is looked up from the node's code. */