From patchwork Fri Jun 30 05:46:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 114569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10125055vqr; Thu, 29 Jun 2023 22:47:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlHZzx19ZUd/RwEbcwgplg4WQWAtw2yvcd+HvQS/tSF2C4KUhizDShv2pU5508KMBKBX2rWb X-Received: by 2002:a17:906:af79:b0:970:71c:df58 with SMTP id os25-20020a170906af7900b00970071cdf58mr952408ejb.42.1688104057853; Thu, 29 Jun 2023 22:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688104057; cv=none; d=google.com; s=arc-20160816; b=anbFW1kIvo86FFXNZuNflTr2mJIbNbaj4bc2zg9Giu8yMwPiiTXFK/nJWW+k4Ba6mQ iQOeMJILhS5ap43QLX3elAu+r0wKuEnCsEh91WojQFE4GbGVr+cbSEFQ7qlIXP4CgG7N qdEK8X7Giwxu5I9PRvQ1CUlcZvThGmvSqN9mRWM9CipWUicOAA/2lXttuFfNzNWb3ywa QZFH6FinFxfr5hJk11gtRd71ZoTOYfzRu+mgE6gOegZsdaCnVKcbXhUeWOqOSTLJWTXg XKG9PkkVxbR1qSpQx3RrNOTyTWC2bzR19gOUlQYTzYHoae+Ge42PGE4yTcNU0/ICj2ZK nt6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:in-reply-to:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=vyyHfsGf+V3Jpi9amYAXwH3KdeZG8FZMUlO4pUAfMMU=; fh=Lfc8OBW/31PQ0FkTc7RwDOLbIvBme7p9mcOBu5xTpzc=; b=fiiAn6RGvBlrybjB37Kp7n4dq+lutOqi0FLs8OQ/icLJIVeJBiiu5YvKImWBPYgi4i s8qU8EbAKe+e3W9KdqOWy5qsFjSfH4bFZKD+DwOgICItdMZURu0Imv+gXulShIpC1U7o DijjK0O37daKRv7z3Quv20l5R5FuT5RwKqoBfceGkIGI3/D+8M5Y0ORUJyGvtDzoCIvs wnlyvWCUl2lKjJAtYCMzayDI2V44tdNKpnIHpN2rpxzQHZEYaz1hzJmuSBGAZNQC+2bk STBFoTnc/ipAV5WANzCIJ1s3vUAVkgtcSIVQX2Ky9rQf0V4zYg5R6Zuyiz4MUJzjf5vl ofGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=unrZVGCJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id k14-20020a17090666ce00b0098718971f52si6883032ejp.87.2023.06.29.22.47.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 22:47:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=unrZVGCJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A86463857726 for ; Fri, 30 Jun 2023 05:47:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A86463857726 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688104056; bh=vyyHfsGf+V3Jpi9amYAXwH3KdeZG8FZMUlO4pUAfMMU=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=unrZVGCJaUNrIAF5m/nGelW2kDVvAo/9Lc0weWq8GLdBTg/x4J5VJiv4p1rsLy9/L ONoFx8nPftqY735tb//NZpYRJep/9rwgORcatXebipZq7FjmqmSmNp5zdFCTpqnzXl y4/wQVD2I8cFkXMmVmdKIJbivFmA+XknsikB/eAY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 69F343858433 for ; Fri, 30 Jun 2023 05:46:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69F343858433 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35U5i5ow016715; Fri, 30 Jun 2023 05:46:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rhs5dr2hh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 05:46:48 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35U5jIrR020035; Fri, 30 Jun 2023 05:46:48 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rhs5dr2gm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 05:46:48 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35TMrlss025390; Fri, 30 Jun 2023 05:46:46 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3rdqre401t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 05:46:46 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35U5kivf21627404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Jun 2023 05:46:44 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D6D020043; Fri, 30 Jun 2023 05:46:44 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB0682004F; Fri, 30 Jun 2023 05:46:41 +0000 (GMT) Received: from [9.200.56.250] (unknown [9.200.56.250]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 30 Jun 2023 05:46:41 +0000 (GMT) Message-ID: <10aee741-5051-deeb-87bc-3b2e797b1a60@linux.ibm.com> Date: Fri, 30 Jun 2023 13:46:40 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH 2/3] ivopts: Call valid_mem_ref_p with code_helper [PR110248] Content-Language: en-US To: GCC Patches Cc: Richard Biener , Richard Sandiford , "Bin.Cheng" References: <7928a68a-cb83-3cd7-eacd-63e3f7c2445c@linux.ibm.com> In-Reply-To: <7928a68a-cb83-3cd7-eacd-63e3f7c2445c@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: DdpfzusH74eZ0rVKjLZxFTiShNxQ8Z3n X-Proofpoint-GUID: 1Zk4NtXgwTi4R-qEkqNwjxHshinXa4Sd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_02,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 mlxscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 bulkscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300048 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, 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: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770105400456733231?= X-GMAIL-MSGID: =?utf-8?q?1770105400456733231?= Hi, As PR110248 shows, to get the expected query results for that case internal functions LEN_{LOAD,STORE} is unable to adopt some addressing modes, we need to pass down the related IFN code as well. This patch is to make IVOPTs pass down ifn code for USE_PTR_ADDRESS type uses, it adjusts the related {strict_,}memory_address_addr_space_p and valid_mem_ref_p functions as well. Bootstrapped and regtested on x86_64-redhat-linux and powerpc64{,le}-linux-gnu. Is it ok for trunk? BR, Kewen ----- PR tree-optimization/110248 gcc/ChangeLog: * recog.cc (memory_address_addr_space_p): Add one more argument ch of type code_helper and pass it to targetm.addr_space.legitimate_address_p instead of ERROR_MARK. (offsettable_address_addr_space_p): Update one function pointer with one more argument of type code_helper as its assignees memory_address_addr_space_p and strict_memory_address_addr_space_p have been adjusted, and adjust some call sites with ERROR_MARK. * recog.h (tree.h): New include header file for tree_code ERROR_MARK. (memory_address_addr_space_p): Adjust with one more unnamed argument of type code_helper with default ERROR_MARK. (strict_memory_address_addr_space_p): Likewise. * reload.cc (strict_memory_address_addr_space_p): Add one unnamed argument of type code_helper. * tree-ssa-address.cc (valid_mem_ref_p): Add one more argument ch of type code_helper and pass it to memory_address_addr_space_p. * tree-ssa-address.h (valid_mem_ref_p): Adjust the declaration with one more unnamed argument of type code_helper with default value ERROR_MARK. * tree-ssa-loop-ivopts.cc (get_address_cost): Use ERROR_MARK as code by default, change it with ifn code for USE_PTR_ADDRESS type use, and pass it to all valid_mem_ref_p calls. --- gcc/recog.cc | 13 ++++++------- gcc/recog.h | 10 +++++++--- gcc/reload.cc | 2 +- gcc/tree-ssa-address.cc | 4 ++-- gcc/tree-ssa-address.h | 3 ++- gcc/tree-ssa-loop-ivopts.cc | 18 +++++++++++++----- 6 files changed, 31 insertions(+), 19 deletions(-) -- 2.39.3 diff --git a/gcc/recog.cc b/gcc/recog.cc index 692c258def6..2bff6c03e4d 100644 --- a/gcc/recog.cc +++ b/gcc/recog.cc @@ -1802,8 +1802,8 @@ pop_operand (rtx op, machine_mode mode) for mode MODE in address space AS. */ bool -memory_address_addr_space_p (machine_mode mode ATTRIBUTE_UNUSED, - rtx addr, addr_space_t as) +memory_address_addr_space_p (machine_mode mode ATTRIBUTE_UNUSED, rtx addr, + addr_space_t as, code_helper ch) { #ifdef GO_IF_LEGITIMATE_ADDRESS gcc_assert (ADDR_SPACE_GENERIC_P (as)); @@ -1813,8 +1813,7 @@ memory_address_addr_space_p (machine_mode mode ATTRIBUTE_UNUSED, win: return true; #else - return targetm.addr_space.legitimate_address_p (mode, addr, 0, as, - ERROR_MARK); + return targetm.addr_space.legitimate_address_p (mode, addr, 0, as, ch); #endif } @@ -2430,7 +2429,7 @@ offsettable_address_addr_space_p (int strictp, machine_mode mode, rtx y, rtx z; rtx y1 = y; rtx *y2; - bool (*addressp) (machine_mode, rtx, addr_space_t) = + bool (*addressp) (machine_mode, rtx, addr_space_t, code_helper) = (strictp ? strict_memory_address_addr_space_p : memory_address_addr_space_p); poly_int64 mode_sz = GET_MODE_SIZE (mode); @@ -2469,7 +2468,7 @@ offsettable_address_addr_space_p (int strictp, machine_mode mode, rtx y, *y2 = plus_constant (address_mode, *y2, mode_sz - 1); /* Use QImode because an odd displacement may be automatically invalid for any wider mode. But it should be valid for a single byte. */ - good = (*addressp) (QImode, y, as); + good = (*addressp) (QImode, y, as, ERROR_MARK); /* In any case, restore old contents of memory. */ *y2 = y1; @@ -2504,7 +2503,7 @@ offsettable_address_addr_space_p (int strictp, machine_mode mode, rtx y, /* Use QImode because an odd displacement may be automatically invalid for any wider mode. But it should be valid for a single byte. */ - return (*addressp) (QImode, z, as); + return (*addressp) (QImode, z, as, ERROR_MARK); } /* Return true if ADDR is an address-expression whose effect depends diff --git a/gcc/recog.h b/gcc/recog.h index badf8e3dc1c..c6ef619c5dd 100644 --- a/gcc/recog.h +++ b/gcc/recog.h @@ -20,6 +20,9 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_RECOG_H #define GCC_RECOG_H +/* For enum tree_code ERROR_MARK. */ +#include "tree.h" + /* Random number that should be large enough for all purposes. Also define a type that has at least MAX_RECOG_ALTERNATIVES + 1 bits, with the extra bit giving an invalid value that can be used to mean "uninitialized". */ @@ -200,11 +203,12 @@ extern void temporarily_undo_changes (int); extern void redo_changes (int); extern bool constrain_operands (int, alternative_mask); extern bool constrain_operands_cached (rtx_insn *, int); -extern bool memory_address_addr_space_p (machine_mode, rtx, addr_space_t); +extern bool memory_address_addr_space_p (machine_mode, rtx, addr_space_t, + code_helper = ERROR_MARK); #define memory_address_p(mode,addr) \ memory_address_addr_space_p ((mode), (addr), ADDR_SPACE_GENERIC) -extern bool strict_memory_address_addr_space_p (machine_mode, rtx, - addr_space_t); +extern bool strict_memory_address_addr_space_p (machine_mode, rtx, addr_space_t, + code_helper = ERROR_MARK); #define strict_memory_address_p(mode,addr) \ strict_memory_address_addr_space_p ((mode), (addr), ADDR_SPACE_GENERIC) extern bool validate_replace_rtx_subexp (rtx, rtx, rtx_insn *, rtx *); diff --git a/gcc/reload.cc b/gcc/reload.cc index 0be21f7b61e..2126bdd117c 100644 --- a/gcc/reload.cc +++ b/gcc/reload.cc @@ -2162,7 +2162,7 @@ hard_reg_set_here_p (unsigned int beg_regno, unsigned int end_regno, rtx x) bool strict_memory_address_addr_space_p (machine_mode mode ATTRIBUTE_UNUSED, - rtx addr, addr_space_t as) + rtx addr, addr_space_t as, code_helper) { #ifdef GO_IF_LEGITIMATE_ADDRESS gcc_assert (ADDR_SPACE_GENERIC_P (as)); diff --git a/gcc/tree-ssa-address.cc b/gcc/tree-ssa-address.cc index 0aaddde8d02..b942799f6f5 100644 --- a/gcc/tree-ssa-address.cc +++ b/gcc/tree-ssa-address.cc @@ -344,7 +344,7 @@ tree_mem_ref_addr (tree type, tree mem_ref) bool valid_mem_ref_p (machine_mode mode, addr_space_t as, - struct mem_address *addr) + struct mem_address *addr, code_helper ch) { rtx address; @@ -352,7 +352,7 @@ valid_mem_ref_p (machine_mode mode, addr_space_t as, if (!address) return false; - return memory_address_addr_space_p (mode, address, as); + return memory_address_addr_space_p (mode, address, as, ch); } /* Checks whether a TARGET_MEM_REF with type TYPE and parameters given by ADDR diff --git a/gcc/tree-ssa-address.h b/gcc/tree-ssa-address.h index 2eadbdef810..faa1cb13745 100644 --- a/gcc/tree-ssa-address.h +++ b/gcc/tree-ssa-address.h @@ -31,7 +31,8 @@ extern rtx addr_for_mem_ref (struct mem_address *, addr_space_t, bool); extern rtx addr_for_mem_ref (tree exp, addr_space_t as, bool really_expand); extern void get_address_description (tree, struct mem_address *); extern tree tree_mem_ref_addr (tree, tree); -extern bool valid_mem_ref_p (machine_mode, addr_space_t, struct mem_address *); +extern bool valid_mem_ref_p (machine_mode, addr_space_t, struct mem_address *, + code_helper = ERROR_MARK); extern void move_fixed_address_to_symbol (struct mem_address *, class aff_tree *); tree create_mem_ref (gimple_stmt_iterator *, tree, diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc index 6671ff6db5a..30b69a31d0f 100644 --- a/gcc/tree-ssa-loop-ivopts.cc +++ b/gcc/tree-ssa-loop-ivopts.cc @@ -4696,17 +4696,25 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, /* Only true if ratio != 1. */ bool ok_with_ratio_p = false; bool ok_without_ratio_p = false; + code_helper code = ERROR_MARK; + + if (use->type == USE_PTR_ADDRESS) + { + gcall *call = as_a (use->stmt); + gcc_assert (gimple_call_internal_p (call)); + code = gimple_call_internal_fn (call); + } if (!aff_combination_const_p (aff_inv)) { parts.index = integer_one_node; /* Addressing mode "base + index". */ - ok_without_ratio_p = valid_mem_ref_p (mem_mode, as, &parts); + ok_without_ratio_p = valid_mem_ref_p (mem_mode, as, &parts, code); if (ratio != 1) { parts.step = wide_int_to_tree (type, ratio); /* Addressing mode "base + index << scale". */ - ok_with_ratio_p = valid_mem_ref_p (mem_mode, as, &parts); + ok_with_ratio_p = valid_mem_ref_p (mem_mode, as, &parts, code); if (!ok_with_ratio_p) parts.step = NULL_TREE; } @@ -4716,7 +4724,7 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, { parts.offset = wide_int_to_tree (sizetype, aff_inv->offset); /* Addressing mode "base + index [<< scale] + offset". */ - if (!valid_mem_ref_p (mem_mode, as, &parts)) + if (!valid_mem_ref_p (mem_mode, as, &parts, code)) parts.offset = NULL_TREE; else aff_inv->offset = 0; @@ -4729,7 +4737,7 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, /* Addressing mode "symbol + base + index [<< scale] [+ offset]". */ if (parts.symbol != NULL_TREE - && !valid_mem_ref_p (mem_mode, as, &parts)) + && !valid_mem_ref_p (mem_mode, as, &parts, code)) { aff_combination_add_elt (aff_inv, parts.symbol, 1); parts.symbol = NULL_TREE; @@ -4767,7 +4775,7 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, { parts.offset = wide_int_to_tree (sizetype, aff_inv->offset); /* Addressing mode "base + offset". */ - if (!valid_mem_ref_p (mem_mode, as, &parts)) + if (!valid_mem_ref_p (mem_mode, as, &parts, code)) parts.offset = NULL_TREE; else aff_inv->offset = 0;