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: 816182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-462586-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="loqjLITN"; dkim-atps=neutral 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 3xxzct3NmPz9s82 for ; Wed, 20 Sep 2017 22:31:16 +1000 (AEST) 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=oZRL6C0S+5NOM7J8a0yn4txdQ1HU8Xp+3iR1e0MDqjyyMYMZyMtn+ 2VS8gfFxFuXCspKNUwL458WDmvp0FF+xO6dBVUL3Vu7CVaCi+l9hVS4G01r5Urnr Dion+97TaHUU0Zzq/QXCkBw84S5ygRrfPtx7ASakDNLuhlgNDjXn4w= 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=loqjLITNUZ1xBwVetJDQ R0cLlmpJ7NZAbfNnh6Hd2+6pFEt58BVHg8y/Oi7O72iNVk4BKY4lS2NuHXnOOzQY NFUIyH6kEgqDteTFjOFAa4v/kDbrGeVk6le+7lf8seImwYTCzHDO5l+QClrlgSyz jr7Ynyq9bDEc1alN8jHsV1M= 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