From patchwork Wed Sep 20 12:30:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 113114 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp709505qgf; Wed, 20 Sep 2017 05:31:22 -0700 (PDT) X-Received: by 10.99.173.67 with SMTP id y3mr1999988pgo.69.1505910682270; Wed, 20 Sep 2017 05:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505910682; cv=none; d=google.com; s=arc-20160816; b=vOKey+C+sXIeY9OVmH7QaFpiOgBCxVquWle+tWfsvM25XvNaeZ21efFWjqnUPIuiWU w7rQTjwv+8uqiGJk6Q0Z7tT0N51KfI5dqD7O026FR/ZUECVayV03u0eMQtdHFYkmNnDG IWR3s6bLcn/7vs86ZDi2ADyW/3QkDZKwA3xEBcAhZMp2XmhfvLPDU1B5dYyoVVc8R4w+ F6p3MJUBA9nR4sLTy3Qrb0ecHn3GWs1jGM4ee71QZNCw7/TxfOCc1coSDuWRJvKu3yiN 7vphv/p8A+5yW4tk+pYTvjHnRtkR1uK3DWG5fwtyVeuTIt6livoRYQlT5l9YxMrZDc5I Khhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=NBLVi/ZU0jbb+oB3g0z84KH9rpAviIXcIB5l5FgKkgA=; b=rGNfNJZXp39AbkTU6b15qEkvrDLjE/il8kdCyM7mvl0YndIYLtkxH/42HeJ72sgm0D 5xggthkFLu7TvOOJtvD2EGpzoczM9OAjvInr7fEX/TwVf9AOSpUEIr/onIU+T1kbrADt jA2HU+vvTyZr7H/l+eg8n0j5cbPPga6EvQcH02fgCbifGU0klBePA3KzOcXFSuIIPscv YintjEPxnKOfQ8W8+RoENb64L2ol66oGh9F27+NTTiIPiLEe9jGfyxwuQTiOMbXdDdZd A+87S9lr1ZXiGB7Yu3GSIeSAmVwQDSxax1ohtiR9ncopjGLrPCiUl77iVpgDJbFmzmxr YtBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=St83wPi8; spf=pass (google.com: domain of gcc-patches-return-462586-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462586-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id j13si3117930pga.73.2017.09.20.05.31.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 05:31:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462586-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=St83wPi8; spf=pass (google.com: domain of gcc-patches-return-462586-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462586-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=MqUEJEqt0JhLfWlQx3CAs1lB+FZwVYYmODWkz4jCke/UGJLYTyRvx 0FVVfqqAxBolZXsM0u2p9m0ROjRer5c9+Tlae9hk55CCiZJahiX+GUS61gSetKSp 8zMZZle4PJDLgyzG/rdqF5rDlNSHhuy2X62gddbceyHMtnC+DCyEyQ= 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:subject:date:message-id:mime-version:content-type; s= default; bh=XLTM4eCrN6gl+ffp+Z2J81qowng=; b=St83wPi8wT4G+BEZfW+x ebOJF8QElCldazjFdTHzbqH/MFmO/svR+7NuAH9nzAYLqCPhxsbuPxAUbA/YtZXc 2+AScyIvUpc/FvZYkSUvH+kjtFWp1fRMYBOC8tip1qyE/aBeqO1XiyLYlX7yJApz 1hR1vZJjdiWQA6YLgJng3dU= Received: (qmail 72893 invoked by alias); 20 Sep 2017 12:31:09 -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 72816 invoked by uid 89); 20 Sep 2017 12:31:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=choosing X-HELO: mail-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Sep 2017 12:31:01 +0000 Received: by mail-wm0-f45.google.com with SMTP id e71so6725162wmg.4 for ; Wed, 20 Sep 2017 05:31:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=NBLVi/ZU0jbb+oB3g0z84KH9rpAviIXcIB5l5FgKkgA=; b=bfDz8Y87QhKyi9TT2Po+GrEOiISjYx1i8+yi/xGnNG+yG4a32lC0hzNrMWaKG78Aiw bt6k7G6nNFw1VEFqRenHv2dvJPmyZIv65WAWVNCmbseYhJ0Icnf5EpKiEgZ7e0K4gxLu MwADX6jGuzO70JwpgbLTmLwg/PM1z3R0j1YywZ/37r4tP3lyUgm/XnaYdvol47Ppp7rM tfCAygJKq2THZOx77jdZFkHdOBCnH90KzaOrNNwkTF31MWLFw7R+I8cwmunUvzWTa0c+ obzaZc581PV1R5Ssfhi4Ock7Fp4mqXr/OQWcog6AEOU/1zcZw9LlB/knd+PKbF3tAqMi Dq+A== X-Gm-Message-State: AHPjjUiz+/FG/t5lNVN6XEnF6aotS5bOrFQmb7CprcZ2LE5128/rNREX 61s48zIdLfkY5osogqQpv0KTDvtoneM= X-Google-Smtp-Source: AOwi7QDNP3uZ2MBV2Zm1RjHmOJ1V7rfy18sdGkGZLNPuKw+J8LxcXVH7E+9Hk3ui02Nlsf/uiJKYaQ== X-Received: by 10.28.173.1 with SMTP id w1mr3817220wme.3.1505910657137; Wed, 20 Sep 2017 05:30:57 -0700 (PDT) Received: from localhost (92.40.248.127.threembb.co.uk. [92.40.248.127]) by smtp.gmail.com with ESMTPSA id 29sm1796991wrz.77.2017.09.20.05.30.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Sep 2017 05:30:55 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Make more use of simplify_gen_binary Date: Wed, 20 Sep 2017 13:30:53 +0100 Message-ID: <87wp4tzh4y.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch replaces various places that previously used: if (GET_CODE (y) == CONST_INT) ... plus_constant (..., x, [-]INTVAL (y)) ... else ... gen_rtx_PLUS/MINUS (..., x, y) ... with single calls to simplify_gen_binary. This allows them to handle polynomial integers as well as constants. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linus-gnu. OK to install? Richard 2017-09-20 Richard Sandiford Alan Hayward David Sherwood gcc/ * calls.c (compute_argument_addresses): Use simplify_gen_binary rather than choosing between plus_constant and gen_rtx_. * expr.c (emit_push_insn): Likewise. (expand_expr_real_2): Likewise. Index: gcc/calls.c =================================================================== --- gcc/calls.c 2017-09-12 14:27:14.515326027 +0100 +++ gcc/calls.c 2017-09-20 13:28:58.742856729 +0100 @@ -2197,11 +2197,7 @@ compute_argument_addresses (struct arg_d if (POINTER_BOUNDS_P (args[i].tree_value)) continue; - if (CONST_INT_P (offset)) - addr = plus_constant (Pmode, arg_reg, INTVAL (offset)); - else - addr = gen_rtx_PLUS (Pmode, arg_reg, offset); - + addr = simplify_gen_binary (PLUS, Pmode, arg_reg, offset); addr = plus_constant (Pmode, addr, arg_offset); if (args[i].partial != 0) @@ -2231,11 +2227,7 @@ compute_argument_addresses (struct arg_d } set_mem_align (args[i].stack, align); - if (CONST_INT_P (slot_offset)) - addr = plus_constant (Pmode, arg_reg, INTVAL (slot_offset)); - else - addr = gen_rtx_PLUS (Pmode, arg_reg, slot_offset); - + addr = simplify_gen_binary (PLUS, Pmode, arg_reg, slot_offset); addr = plus_constant (Pmode, addr, arg_offset); if (args[i].partial != 0) Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-09-18 14:58:24.371655718 +0100 +++ gcc/expr.c 2017-09-20 13:28:58.743765039 +0100 @@ -4541,15 +4541,8 @@ emit_push_insn (rtx x, machine_mode mode else #endif { - if (CONST_INT_P (args_so_far)) - addr - = memory_address (mode, - plus_constant (Pmode, args_addr, - INTVAL (args_so_far))); - else - addr = memory_address (mode, gen_rtx_PLUS (Pmode, args_addr, - args_so_far)); - dest = gen_rtx_MEM (mode, addr); + addr = simplify_gen_binary (PLUS, Pmode, args_addr, args_so_far); + dest = gen_rtx_MEM (mode, memory_address (mode, addr)); /* We do *not* set_mem_attributes here, because incoming arguments may overlap with sibling call outgoing arguments and we cannot @@ -8565,14 +8558,7 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b { expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, modifier); - - /* If the last operand is a CONST_INT, use plus_constant of - the negated constant. Else make the MINUS. */ - if (CONST_INT_P (op1)) - return REDUCE_BIT_FIELD (plus_constant (mode, op0, - -INTVAL (op1))); - else - return REDUCE_BIT_FIELD (gen_rtx_MINUS (mode, op0, op1)); + return simplify_gen_binary (MINUS, mode, op0, op1); } /* No sense saving up arithmetic to be done