From patchwork Thu Jun 23 03:39:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Hongtao" X-Patchwork-Id: 1646877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=tSqdy6En; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LT5cv3QXYz9sGP for ; Thu, 23 Jun 2022 13:40:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5777E3895FF5 for ; Thu, 23 Jun 2022 03:40:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5777E3895FF5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1655955642; bh=9PgiG8C2TLp6TpBox+Xz7HNTiATf8Nw8PWBv89zOE60=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tSqdy6EnoN5VeK2DMEOAL0/p/qoXJPE0WU/Hy438avt7qR+rIKI6tAOk07krD6wzd cGAvgc9+3ZcM8EwXRlX1kPBZzMzkq0TLrOF2ADXkvmLAQEGGgWoVK8zkJLXseATi9H 9g6G/mVR+9hY5KWgbIk81k4wIhBpCVMTs1yuKWq4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by sourceware.org (Postfix) with ESMTPS id 9DFC73895FFA for ; Thu, 23 Jun 2022 03:39:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9DFC73895FFA X-IronPort-AV: E=McAfee;i="6400,9594,10386"; a="278163922" X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="278163922" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2022 20:39:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="655983911" Received: from scymds01.sc.intel.com ([10.148.94.138]) by fmsmga004.fm.intel.com with ESMTP; 22 Jun 2022 20:39:18 -0700 Received: from shliclel051.sh.intel.com (shliclel051.sh.intel.com [10.239.236.51]) by scymds01.sc.intel.com with ESMTP id 25N3dGOf027816; Wed, 22 Jun 2022 20:39:17 -0700 To: gcc-patches@gcc.gnu.org Subject: [PATCH] Improve reg_or_subregno to return INVALID_REGNUM when the subreg of memory is processed. Date: Thu, 23 Jun 2022 11:39:16 +0800 Message-Id: <20220623033916.32217-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.18.1 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: liuhongt via Gcc-patches From: "Liu, Hongtao" Reply-To: liuhongt Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi: This is follow-up to [1], return INVALID_REGNUM instead of gcc_assert, also adjust some conditions guarded for reg_or_subregno. >OK, but I think that reg_or_subregno should be improved to return >INVALID_REGNUM when the subreg of memory is processed. > >Thanks, >Uros. [1] https://gcc.gnu.org/pipermail/gcc-patches/2022-June/596841.html Bootstrapped and regtested on x86_64-pc-linux{-m32,}. Ok for trunk? gcc/ChangeLog: * combine.cc (try_combine): Replace condition with regno != INVALID_REGNUM. * jump.cc (reg_or_subregno): Remove condition for (REG_P (x) || (SUBREG_P (x) && REG_P (SUBREG_REG (x)))). * reload.cc (push_reload): Ditto. --- gcc/combine.cc | 7 ++----- gcc/jump.cc | 4 ++-- gcc/reload.cc | 4 ---- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/gcc/combine.cc b/gcc/combine.cc index 9a34ef847aa..3e6feb323f7 100644 --- a/gcc/combine.cc +++ b/gcc/combine.cc @@ -4245,12 +4245,9 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, if (GET_CODE (x) == PARALLEL) x = XVECEXP (newi2pat, 0, 0); - if (REG_P (SET_DEST (x)) - || (GET_CODE (SET_DEST (x)) == SUBREG - && REG_P (SUBREG_REG (SET_DEST (x))))) + unsigned int regno = reg_or_subregno (SET_DEST (x)); + if (regno != INVALID_REGNUM) { - unsigned int regno = reg_or_subregno (SET_DEST (x)); - bool done = false; for (rtx_insn *insn = NEXT_INSN (i3); !done diff --git a/gcc/jump.cc b/gcc/jump.cc index 332f86878e1..dd8fb50e08e 100644 --- a/gcc/jump.cc +++ b/gcc/jump.cc @@ -1889,6 +1889,6 @@ reg_or_subregno (const_rtx reg) { if (GET_CODE (reg) == SUBREG) reg = SUBREG_REG (reg); - gcc_assert (REG_P (reg)); - return REGNO (reg); + + return REG_P (reg) ? REGNO (reg) : INVALID_REGNUM; } diff --git a/gcc/reload.cc b/gcc/reload.cc index 3ed901e3944..c7f4fc9d965 100644 --- a/gcc/reload.cc +++ b/gcc/reload.cc @@ -1369,8 +1369,6 @@ push_reload (rtx in, rtx out, rtx *inloc, rtx *outloc, if (subreg_in_class == NO_REGS && in != 0 - && (REG_P (in) - || (GET_CODE (in) == SUBREG && REG_P (SUBREG_REG (in)))) && reg_or_subregno (in) < FIRST_PSEUDO_REGISTER) subreg_in_class = REGNO_REG_CLASS (reg_or_subregno (in)); /* If a memory location is needed for the copy, make one. */ @@ -1401,8 +1399,6 @@ push_reload (rtx in, rtx out, rtx *inloc, rtx *outloc, n_reloads++; if (out != 0 - && (REG_P (out) - || (GET_CODE (out) == SUBREG && REG_P (SUBREG_REG (out)))) && reg_or_subregno (out) < FIRST_PSEUDO_REGISTER && (targetm.secondary_memory_needed (outmode, rclass, REGNO_REG_CLASS (reg_or_subregno (out)))))