From patchwork Sat Nov 9 10:03:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 289959 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 B58C02C00AD for ; Sat, 9 Nov 2013 21:04:01 +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=ndXAtS3KvOwMZb4ZI4WrrWiYo3PCeI795zOVsYE0/7IaRlMGGv 1Z+NKwcOrgM1BlGqLmJADwDl1TeA0Ox+YTDvIlZ9QL1G5doOoqjZZ8FmDReCToQL zNdNOeBGndOgKfDopi+sOK5uqEcxrYEZe1N7mh/PxsC7ruAt0BnHpwDHY= 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=dqrqO2z//IKCaGUKmNQBubYEQu8=; b=ITyppix4Zgfby9S5oEXI GC7ZViMI9tQ6lfpbJeW3TKJ0qZpMwRnGuKGUaj9JGzGBA+ZqO/1fja7smUzO6Hz3 7TA0VGwKsNXJKiv7IhAbns/MUsMQgXi7qJqr7Iq8Gd5NRZADIT70As7TtN1CCCIw wplyoWC9qaS1t+A4UTu4azg= Received: (qmail 11197 invoked by alias); 9 Nov 2013 10:03:53 -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 11188 invoked by uid 89); 9 Nov 2013 10:03:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 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-f181.google.com Received: from Unknown (HELO mail-wi0-f181.google.com) (209.85.212.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 09 Nov 2013 10:03:52 +0000 Received: by mail-wi0-f181.google.com with SMTP id m19so425792wiv.14 for ; Sat, 09 Nov 2013 02:03:43 -0800 (PST) X-Received: by 10.180.92.10 with SMTP id ci10mr5479922wib.41.1383991423093; Sat, 09 Nov 2013 02:03:43 -0800 (PST) Received: from localhost ([2.28.235.51]) by mx.google.com with ESMTPSA id bs15sm13632505wib.10.2013.11.09.02.03.42 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Sat, 09 Nov 2013 02:03:42 -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] A few assorted simplifications Date: Sat, 09 Nov 2013 10:03:42 +0000 Message-ID: <87a9hdhoxt.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 These changes don't have much in common except being simplifications. Note that "len == 0" isn't possible now that we've eliminated the 0-precision case. "val = val" should be redundant. Tested on powerpc64-linux-gnu and by rerunning the assembly comparison. OK to install? Richard Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2013-11-09 09:39:17.841740772 +0000 +++ gcc/expmed.c 2013-11-09 09:39:27.370805176 +0000 @@ -3652,7 +3652,7 @@ expand_smod_pow2 (enum machine_mode mode modulus. By including the signbit in the operation, many targets can avoid an explicit compare operation in the following comparison against zero. */ - wide_int mask = wi::mask (logd, false, GET_MODE_PRECISION (mode)); + wide_int mask = wi::mask (logd, false, prec); mask = wi::set_bit (mask, prec - 1); temp = expand_binop (mode, and_optab, op0, @@ -3667,7 +3667,7 @@ expand_smod_pow2 (enum machine_mode mode temp = expand_binop (mode, sub_optab, result, const1_rtx, result, 0, OPTAB_LIB_WIDEN); - mask = wi::mask (logd, true, GET_MODE_PRECISION (mode)); + mask = wi::mask (logd, true, prec); temp = expand_binop (mode, ior_optab, temp, immed_wide_int_const (mask, mode), result, 1, OPTAB_LIB_WIDEN); Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2013-11-09 09:39:26.729800844 +0000 +++ gcc/fold-const.c 2013-11-09 09:39:27.373805197 +0000 @@ -7175,8 +7175,7 @@ fold_plusminus_mult_expr (location_t loc arg10 = build_one_cst (type); /* As we canonicalize A - 2 to A + -2 get rid of that sign for the purpose of this canonicalization. */ - if (TYPE_SIGN (TREE_TYPE (arg1)) == SIGNED - && wi::neg_p (arg1) + if (wi::neg_p (arg1, TYPE_SIGN (TREE_TYPE (arg1))) && negate_expr_p (arg1) && code == PLUS_EXPR) { Index: gcc/real.c =================================================================== --- gcc/real.c 2013-11-09 09:39:26.732800864 +0000 +++ gcc/real.c 2013-11-09 09:39:27.373805197 +0000 @@ -1422,7 +1422,7 @@ real_to_integer (const REAL_VALUE_TYPE * words = (precision + HOST_BITS_PER_WIDE_INT - 1) / HOST_BITS_PER_WIDE_INT; - for (int i = 0; i < 2 * MAX_BITSIZE_MODE_ANY_INT / HOST_BITS_PER_WIDE_INT; i++) + for (unsigned int i = 0; i < ARRAY_SIZE (val); i++) val[i] = 0; #if (HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG) @@ -2205,16 +2205,11 @@ real_from_integer (REAL_VALUE_TYPE *r, e r->cl = rvc_normal; r->sign = wi::neg_p (val_in, sgn); - if (len == 0) - len = 1; - /* We have to ensure we can negate the largest negative number. */ wide_int val = wide_int::from (val_in, maxbitlen, sgn); if (r->sign) val = -val; - else - val = val; /* Ensure a multiple of HOST_BITS_PER_WIDE_INT, ceiling, as elt won't work with precisions that are not a multiple of