From patchwork Tue Apr 22 20:02:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 341456 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 14CB11400F9 for ; Wed, 23 Apr 2014 06:02:17 +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:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=IuiuFocpkmDG0Gw6c6sGXtrhkF4mhoX2FyWRsFAYVq5j9QVPrJ HaKSgSdzETqLt49Qd8hYDSnCmVIWnxsghI9PQXJPm+ji5FpsoNQis0aWreN62DOe YXJQOk++kY4PkSl4LqvoDY0u+7d+onTTzUDAtUniPLGV2wTR2JmXYBFBU= 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=if9Z/TvFCINjytNHgEStETbEhNI=; b=CyqPiVeTX03/ignAqyXs 2htWCoOzIt/q7zs50ENK4VwxiYCs7h5r2K13wFxn4Oeu2OTlJ44rIhW25CN+HDqa ojpFk/eSbkvs6f+qGaZirRvjebJkAANg0eKBKGd1rxAMidBLcnxOXkkEhD5Lz70q S884/KjCMuSP4oOtUQGA2k0= Received: (qmail 28003 invoked by alias); 22 Apr 2014 20:02:10 -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 27992 invoked by uid 89); 22 Apr 2014 20:02:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f178.google.com Received: from mail-wi0-f178.google.com (HELO mail-wi0-f178.google.com) (209.85.212.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 22 Apr 2014 20:02:08 +0000 Received: by mail-wi0-f178.google.com with SMTP id bs8so130354wib.17 for ; Tue, 22 Apr 2014 13:02:05 -0700 (PDT) X-Received: by 10.194.1.242 with SMTP id 18mr35980702wjp.22.1398196925341; Tue, 22 Apr 2014 13:02:05 -0700 (PDT) Received: from localhost ([2.26.169.52]) by mx.google.com with ESMTPSA id wl6sm63281105wjb.3.2014.04.22.13.02.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Apr 2014 13:02:04 -0700 (PDT) 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 5/8] Use LOG2_BITS_PER_UNIT Date: Tue, 22 Apr 2014 21:02:04 +0100 Message-ID: <87r44pdtfn.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Looks like a few uses of the old idiom: BITS_PER_UNIT == 8 ? 3 : exact_log2 (BITS_PER_UNIT) have crept in. This patch replaces them with LOG2_BITS_PER_UNIT. Tested on x86_64-linux-gnu. OK to install? Thanks, Richard Index: gcc/expr.c =================================================================== --- gcc/expr.c 2014-04-22 20:58:26.969683484 +0100 +++ gcc/expr.c 2014-04-22 21:00:26.377614881 +0100 @@ -6801,8 +6801,7 @@ get_inner_reference (tree exp, HOST_WIDE if (!integer_zerop (off)) { offset_int boff, coff = mem_ref_offset (exp); - boff = wi::lshift (coff, (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + boff = wi::lshift (coff, LOG2_BITS_PER_UNIT); bit_offset += boff; } exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); @@ -6828,8 +6827,7 @@ get_inner_reference (tree exp, HOST_WIDE { offset_int tem = wi::sext (wi::to_offset (offset), TYPE_PRECISION (sizetype)); - tem = wi::lshift (tem, (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + tem = wi::lshift (tem, LOG2_BITS_PER_UNIT); tem += bit_offset; if (wi::fits_shwi_p (tem)) { @@ -6844,16 +6842,12 @@ get_inner_reference (tree exp, HOST_WIDE /* Avoid returning a negative bitpos as this may wreak havoc later. */ if (wi::neg_p (bit_offset)) { - offset_int mask - = wi::mask (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT), - false); + offset_int mask = wi::mask (LOG2_BITS_PER_UNIT, false); offset_int tem = bit_offset.and_not (mask); /* TEM is the bitpos rounded to BITS_PER_UNIT towards -Inf. Subtract it to BIT_OFFSET and add it (scaled) to OFFSET. */ bit_offset -= tem; - tem = wi::arshift (tem, (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + tem = wi::arshift (tem, LOG2_BITS_PER_UNIT); offset = size_binop (PLUS_EXPR, offset, wide_int_to_tree (sizetype, tem)); } Index: gcc/tree-dfa.c =================================================================== --- gcc/tree-dfa.c 2014-04-22 20:58:27.020683881 +0100 +++ gcc/tree-dfa.c 2014-04-22 21:00:26.378614888 +0100 @@ -463,10 +463,7 @@ get_ref_base_and_extent (tree exp, HOST_ { offset_int tem = (wi::to_offset (ssize) - wi::to_offset (fsize)); - if (BITS_PER_UNIT == 8) - tem = wi::lshift (tem, 3); - else - tem *= BITS_PER_UNIT; + tem = wi::lshift (tem, LOG2_BITS_PER_UNIT); tem -= woffset; maxsize += tem; } @@ -583,8 +580,7 @@ get_ref_base_and_extent (tree exp, HOST_ else { offset_int off = mem_ref_offset (exp); - off = wi::lshift (off, (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + off = wi::lshift (off, LOG2_BITS_PER_UNIT); off += bit_offset; if (wi::fits_shwi_p (off)) { Index: gcc/tree-ssa-alias.c =================================================================== --- gcc/tree-ssa-alias.c 2014-04-22 20:58:26.969683484 +0100 +++ gcc/tree-ssa-alias.c 2014-04-22 21:00:26.378614888 +0100 @@ -1041,8 +1041,7 @@ indirect_ref_may_alias_decl_p (tree ref1 /* The offset embedded in MEM_REFs can be negative. Bias them so that the resulting offset adjustment is positive. */ offset_int moff = mem_ref_offset (base1); - moff = wi::lshift (moff, (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + moff = wi::lshift (moff, LOG2_BITS_PER_UNIT); if (wi::neg_p (moff)) offset2p += (-moff).to_short_addr (); else @@ -1118,8 +1117,7 @@ indirect_ref_may_alias_decl_p (tree ref1 || TREE_CODE (dbase2) == TARGET_MEM_REF) { offset_int moff = mem_ref_offset (dbase2); - moff = wi::lshift (moff, (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + moff = wi::lshift (moff, LOG2_BITS_PER_UNIT); if (wi::neg_p (moff)) doffset1 -= (-moff).to_short_addr (); else @@ -1217,15 +1215,13 @@ indirect_refs_may_alias_p (tree ref1 ATT /* The offset embedded in MEM_REFs can be negative. Bias them so that the resulting offset adjustment is positive. */ moff = mem_ref_offset (base1); - moff = wi::lshift (moff, (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + moff = wi::lshift (moff, LOG2_BITS_PER_UNIT); if (wi::neg_p (moff)) offset2 += (-moff).to_short_addr (); else offset1 += moff.to_shwi (); moff = mem_ref_offset (base2); - moff = wi::lshift (moff, (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + moff = wi::lshift (moff, LOG2_BITS_PER_UNIT); if (wi::neg_p (moff)) offset1 += (-moff).to_short_addr (); else @@ -2200,12 +2196,10 @@ stmt_kills_ref_p_1 (gimple stmt, ao_ref TREE_OPERAND (ref->base, 1))) { offset_int off1 = mem_ref_offset (base); - off1 = wi::lshift (off1, (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + off1 = wi::lshift (off1, LOG2_BITS_PER_UNIT); off1 += offset; offset_int off2 = mem_ref_offset (ref->base); - off2 = wi::lshift (off2, (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + off2 = wi::lshift (off2, LOG2_BITS_PER_UNIT); off2 += ref_offset; if (wi::fits_shwi_p (off1) && wi::fits_shwi_p (off2)) { Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c 2014-04-22 20:58:26.969683484 +0100 +++ gcc/tree-ssa-sccvn.c 2014-04-22 21:00:26.378614888 +0100 @@ -817,8 +817,7 @@ copy_reference_ops_from_ref (tree ref, v offset_int off = (wi::to_offset (this_offset) + wi::lrshift (wi::to_offset (bit_offset), - BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + LOG2_BITS_PER_UNIT)); if (wi::fits_shwi_p (off) /* Probibit value-numbering zero offset components of addresses the same before the pass folding