From patchwork Thu Jul 13 08:55:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107635 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1938100qge; Thu, 13 Jul 2017 01:57:40 -0700 (PDT) X-Received: by 10.99.185.25 with SMTP id z25mr8068860pge.273.1499936260435; Thu, 13 Jul 2017 01:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936260; cv=none; d=google.com; s=arc-20160816; b=ESk1p/azw7Omghs6jJzqqWCG2IEk9Z7tmnRsSE+sApAdrOGNUY7Vip7NsUZ21uwn+G e8g6uZX/Zu9NiniN4a7VUzPtP8MVeUo4cmEz8eqj7SJDwX9B6BlLaxX5b7qEdw1D9I+Z PWVvEFCT/nH667B5X7IWIgksrxrrFR/DvN93ICjZ92jBNGSaUgu9jjyWb4xRiU91tx5m UY3PGbXFRyBLHeJriRpdoSyoCRMh4yu8NtG58uwBXuLSnksOMxB640TDDM29y8F55toH hLQ/eHOvgsHlLFLDrEae422kVagBeEzTj9AyP1tsGBJ8VXeJxvo8y5JbOz2xd/+9hF2N g0rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :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=77ocFSiCmtipTKD1YA1muEw6q2LMtd6EWJA8BN+9KE0=; b=VdTyC06mRWto24MpWVWaeo9deuK8nC0x/xaQKe3wIVOnneg5NiAoCtn17PF8n6BaiZ QoW2uYLgUPbGKZionywnprxNLl1ghdlbcT1Sr1eSmmm9qzJV/bBRIgcbigdtQskTa76c oRbHYq0P9fr0AZ+FNWzu3HqSCzaoHmFiVW8E2l5mAv6mcJ1jiTXP4JpKTqO5YvUbfg+N izuXy5UsEHyb22F8LB6+NBlb7Eo4AcGuIW5CPOrA1lUdTz6oua64YdQdEBsSX/zHThzQ DrsGYfhEhZSM1pt8EZI9LvOgLU2ysUS4WJ5jWSkxdRnoQPz7B3ZOaj7IURA8sVn0lKRk 6H3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=MLEavWUw; spf=pass (google.com: domain of gcc-patches-return-458040-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458040-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 p7si3952917pll.609.2017.07.13.01.57.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:57:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458040-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.b=MLEavWUw; spf=pass (google.com: domain of gcc-patches-return-458040-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458040-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:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=ogVx36zvBkopMLJsXUP6ActmY43D6 3FIPiLCBLPExg5GnKlWMffCaAC8w2yvAv7Xo/tmXw2Xt96rGhp24/zrkOhDBRwo/ 7IklePRnUf35yUItJg7QZNsKfh6k9pGmiQAAfUjFyQJ11fAniUvuSRQIsAkjmaI+ 7CveFzB5poA6Gc= 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:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=GYsWmFSM8YFrtKXlLOWZsLpLnks=; b=MLE avWUwd73GNREgA2jtcuy9FX+7Bn+Vti/LzW6SKNQxHgODMUDABRaDxFv5eZz6Vy5 /ibi39zTd99qWyWRO8vgHgmKf3s2VvhsrO+4Klffy/XMMayas7ER+hAzSbF1wt+2 6V6rrLleRxF4+QIZroBMqfgu5GDBW/NJHEkcr5xc= Received: (qmail 125078 invoked by alias); 13 Jul 2017 08:55:54 -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 124329 invoked by uid 89); 13 Jul 2017 08:55:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=8615 X-HELO: mail-wr0-f171.google.com Received: from mail-wr0-f171.google.com (HELO mail-wr0-f171.google.com) (209.85.128.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:55:50 +0000 Received: by mail-wr0-f171.google.com with SMTP id c11so49485208wrc.3 for ; Thu, 13 Jul 2017 01:55:50 -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:references:date :in-reply-to:message-id:user-agent:mime-version; bh=77ocFSiCmtipTKD1YA1muEw6q2LMtd6EWJA8BN+9KE0=; b=OzA8ZA1fGymFTHbmCN0jFA7F9fNhx8jl2K1HHXXrZDXBq4W092+evJ5hT1rR7Selp/ OXaGyJcvYLM4D/JXmYUjegvLPFkfCMOBt2ewCkyQnPIX5hLXn9kXpSP9bNiWjbP7FCI3 bg+S8Vodc+h54St3g6fZbEJ+WhQ3v11HSqJ0UcDTvMiNy1v6YHxtqDFvvBuMOGL4yGuk INmWzx1/IQmCtSSzJl7xUrQV0/q2NXRQkiQ6ufH+llR8EMDWKQUi6pew8JxlIPEMe25D tIMVNZlbv9lK1NSBI2Hdhl+JPDssz/WtGpHoP9CCFr9VixXg3x+TzsDz7Dl6rbggnmHw TSyQ== X-Gm-Message-State: AIVw111kCzJkI/selzD0fp3O/21gyQe9N1Cf6+bLRpw3gG4fxH4quEHP nwfM5wGQb4vE+qZFzX3ZAg== X-Received: by 10.223.170.194 with SMTP id i2mr1039688wrc.143.1499936148545; Thu, 13 Jul 2017 01:55:48 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id n31sm4983220wrn.59.2017.07.13.01.55.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:55:47 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [49/77] Simplify nonzero/num_sign_bits hooks References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:55:46 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87a848g1gt.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The two implementations of the reg_nonzero_bits and reg_num_sign_bits hooks ignored the "known_x", "known_mode" and "known_ret" arguments, so this patch removes them. It adds a new scalar_int_mode parameter that specifies the mode of "x". (This mode might be different from "mode", which is the mode in which "x" is used.) 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * rtl.h (rtl_hooks::reg_nonzero_bits): Add a scalar_int_mode parameter for the mode of "x". Remove the "known_x", "known_mode" and "known_ret" arguments. Change the type of the mode argument to scalar_int_mode. (rtl_hooks:reg_num_sign_bit_copies): Likewise. * combine.c (reg_nonzero_bits_for_combine): Update accordingly. (reg_num_sign_bit_copies_for_combine): Likewise. * rtlanal.c (nonzero_bits1): Likewise. (num_sign_bit_copies1): Likewise. * rtlhooks-def.h (reg_nonzero_bits_general): Likewise. (reg_num_sign_bit_copies_general): Likewise. * rtlhooks.c (reg_num_sign_bit_copies_general): Likewise. (reg_nonzero_bits_general): Likewise. Index: gcc/rtl.h =================================================================== --- gcc/rtl.h 2017-07-13 09:18:32.528352705 +0100 +++ gcc/rtl.h 2017-07-13 09:18:45.761227536 +0100 @@ -3764,10 +3764,10 @@ struct rtl_hooks { rtx (*gen_lowpart) (machine_mode, rtx); rtx (*gen_lowpart_no_emit) (machine_mode, rtx); - rtx (*reg_nonzero_bits) (const_rtx, machine_mode, const_rtx, machine_mode, - unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT *); - rtx (*reg_num_sign_bit_copies) (const_rtx, machine_mode, const_rtx, machine_mode, - unsigned int, unsigned int *); + rtx (*reg_nonzero_bits) (const_rtx, scalar_int_mode, scalar_int_mode, + unsigned HOST_WIDE_INT *); + rtx (*reg_num_sign_bit_copies) (const_rtx, scalar_int_mode, scalar_int_mode, + unsigned int *); bool (*reg_truncated_to_mode) (machine_mode, const_rtx); /* Whenever you add entries here, make sure you adjust rtlhooks-def.h. */ Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:44.175354711 +0100 +++ gcc/combine.c 2017-07-13 09:18:45.761227536 +0100 @@ -414,13 +414,12 @@ struct undobuf static int n_occurrences; -static rtx reg_nonzero_bits_for_combine (const_rtx, machine_mode, const_rtx, - machine_mode, - unsigned HOST_WIDE_INT, +static rtx reg_nonzero_bits_for_combine (const_rtx, scalar_int_mode, + scalar_int_mode, unsigned HOST_WIDE_INT *); -static rtx reg_num_sign_bit_copies_for_combine (const_rtx, machine_mode, const_rtx, - machine_mode, - unsigned int, unsigned int *); +static rtx reg_num_sign_bit_copies_for_combine (const_rtx, scalar_int_mode, + scalar_int_mode, + unsigned int *); static void do_SUBST (rtx *, rtx); static void do_SUBST_INT (int *, int); static void init_reg_last (void); @@ -10057,17 +10056,15 @@ simplify_and_const_int (rtx x, scalar_in return x; } -/* Given a REG, X, compute which bits in X can be nonzero. +/* Given a REG X of mode XMODE, compute which bits in X can be nonzero. We don't care about bits outside of those defined in MODE. For most X this is simply GET_MODE_MASK (GET_MODE (MODE)), but if X is a shift, AND, or zero_extract, we can do better. */ static rtx -reg_nonzero_bits_for_combine (const_rtx x, machine_mode mode, - const_rtx known_x ATTRIBUTE_UNUSED, - machine_mode known_mode ATTRIBUTE_UNUSED, - unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED, +reg_nonzero_bits_for_combine (const_rtx x, scalar_int_mode xmode, + scalar_int_mode mode, unsigned HOST_WIDE_INT *nonzero) { rtx tem; @@ -10108,8 +10105,7 @@ reg_nonzero_bits_for_combine (const_rtx if (tem) { if (SHORT_IMMEDIATES_SIGN_EXTEND) - tem = sign_extend_short_imm (tem, GET_MODE (x), - GET_MODE_PRECISION (mode)); + tem = sign_extend_short_imm (tem, xmode, GET_MODE_PRECISION (mode)); return tem; } @@ -10118,9 +10114,9 @@ reg_nonzero_bits_for_combine (const_rtx { unsigned HOST_WIDE_INT mask = rsp->nonzero_bits; - if (GET_MODE_PRECISION (GET_MODE (x)) < GET_MODE_PRECISION (mode)) + if (GET_MODE_PRECISION (xmode) < GET_MODE_PRECISION (mode)) /* We don't know anything about the upper bits. */ - mask |= GET_MODE_MASK (mode) ^ GET_MODE_MASK (GET_MODE (x)); + mask |= GET_MODE_MASK (mode) ^ GET_MODE_MASK (xmode); *nonzero &= mask; } @@ -10128,17 +10124,14 @@ reg_nonzero_bits_for_combine (const_rtx return NULL; } -/* Return the number of bits at the high-order end of X that are known to - be equal to the sign bit. X will be used in mode MODE; if MODE is - VOIDmode, X will be used in its own mode. The returned value will always - be between 1 and the number of bits in MODE. */ +/* Given a reg X of mode XMODE, return the number of bits at the high-order + end of X that are known to be equal to the sign bit. X will be used + in mode MODE; the returned value will always be between 1 and the + number of bits in MODE. */ static rtx -reg_num_sign_bit_copies_for_combine (const_rtx x, machine_mode mode, - const_rtx known_x ATTRIBUTE_UNUSED, - machine_mode known_mode - ATTRIBUTE_UNUSED, - unsigned int known_ret ATTRIBUTE_UNUSED, +reg_num_sign_bit_copies_for_combine (const_rtx x, scalar_int_mode xmode, + scalar_int_mode mode, unsigned int *result) { rtx tem; @@ -10167,7 +10160,7 @@ reg_num_sign_bit_copies_for_combine (con return tem; if (nonzero_sign_valid && rsp->sign_bit_copies != 0 - && GET_MODE_PRECISION (GET_MODE (x)) == GET_MODE_PRECISION (mode)) + && GET_MODE_PRECISION (xmode) == GET_MODE_PRECISION (mode)) *result = rsp->sign_bit_copies; return NULL; Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:45.323262480 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:45.762227456 +0100 @@ -4449,9 +4449,8 @@ nonzero_bits1 (const_rtx x, scalar_int_m { unsigned HOST_WIDE_INT nonzero_for_hook = nonzero; - rtx new_rtx = rtl_hooks.reg_nonzero_bits (x, mode, known_x, - known_mode, known_ret, - &nonzero_for_hook); + rtx new_rtx = rtl_hooks.reg_nonzero_bits (x, xmode, mode, + &nonzero_for_hook); if (new_rtx) nonzero_for_hook &= cached_nonzero_bits (new_rtx, mode, known_x, @@ -4943,9 +4942,8 @@ num_sign_bit_copies1 (const_rtx x, scala { unsigned int copies_for_hook = 1, copies = 1; - rtx new_rtx = rtl_hooks.reg_num_sign_bit_copies (x, mode, known_x, - known_mode, known_ret, - &copies_for_hook); + rtx new_rtx = rtl_hooks.reg_num_sign_bit_copies (x, xmode, mode, + &copies_for_hook); if (new_rtx) copies = cached_num_sign_bit_copies (new_rtx, mode, known_x, Index: gcc/rtlhooks-def.h =================================================================== --- gcc/rtlhooks-def.h 2017-02-23 19:54:15.000000000 +0000 +++ gcc/rtlhooks-def.h 2017-07-13 09:18:45.762227456 +0100 @@ -38,13 +38,11 @@ #define RTL_HOOKS_INITIALIZER { \ } extern rtx gen_lowpart_general (machine_mode, rtx); -extern rtx reg_nonzero_bits_general (const_rtx, machine_mode, const_rtx, - machine_mode, - unsigned HOST_WIDE_INT, +extern rtx reg_nonzero_bits_general (const_rtx, scalar_int_mode, + scalar_int_mode, unsigned HOST_WIDE_INT *); -extern rtx reg_num_sign_bit_copies_general (const_rtx, machine_mode, const_rtx, - machine_mode, - unsigned int, unsigned int *); +extern rtx reg_num_sign_bit_copies_general (const_rtx, scalar_int_mode, + scalar_int_mode, unsigned int *); extern bool reg_truncated_to_mode_general (machine_mode, const_rtx); #endif /* GCC_RTL_HOOKS_DEF_H */ Index: gcc/rtlhooks.c =================================================================== --- gcc/rtlhooks.c 2017-07-13 09:18:32.528352705 +0100 +++ gcc/rtlhooks.c 2017-07-13 09:18:45.762227456 +0100 @@ -86,23 +86,15 @@ gen_lowpart_general (machine_mode mode, } rtx -reg_num_sign_bit_copies_general (const_rtx x ATTRIBUTE_UNUSED, - machine_mode mode ATTRIBUTE_UNUSED, - const_rtx known_x ATTRIBUTE_UNUSED, - machine_mode known_mode ATTRIBUTE_UNUSED, - unsigned int known_ret ATTRIBUTE_UNUSED, - unsigned int *result ATTRIBUTE_UNUSED) +reg_num_sign_bit_copies_general (const_rtx, scalar_int_mode, scalar_int_mode, + unsigned int *) { return NULL; } rtx -reg_nonzero_bits_general (const_rtx x ATTRIBUTE_UNUSED, - machine_mode mode ATTRIBUTE_UNUSED, - const_rtx known_x ATTRIBUTE_UNUSED, - machine_mode known_mode ATTRIBUTE_UNUSED, - unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED, - unsigned HOST_WIDE_INT *nonzero ATTRIBUTE_UNUSED) +reg_nonzero_bits_general (const_rtx, scalar_int_mode, scalar_int_mode, + unsigned HOST_WIDE_INT *) { return NULL; }