public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-910] Avoid marking TARGET_MEM_REF bases addressable Date: Wed, 19 May 2021 12:54:09 +0000 (GMT) [thread overview] Message-ID: <20210519125409.22ECB393A400@sourceware.org> (raw) https://gcc.gnu.org/g:35a16e4b38eb9faf212de9814f17a5215fa5538a commit r12-910-g35a16e4b38eb9faf212de9814f17a5215fa5538a Author: Richard Biener <rguenther@suse.de> Date: Wed May 19 12:36:19 2021 +0200 Avoid marking TARGET_MEM_REF bases addressable The following does no longer mark TARGET_MEM_REF bases addressable, mimicing MEM_REFs beahvior here. In contrast to the latter, TARGET_MEM_REF RTL expansion expects to always operate on memory though, so make sure we expand them so. 2021-05-19 Richard Biener <rguenther@suse.de> * cfgexpand.c (discover_nonconstant_array_refs_r): Make sure TARGET_MEM_REF bases are expanded as memory. * tree-ssa-operands.c (operands_scanner::get_tmr_operands): Do not mark TARGET_MEM_REF bases addressable. * tree-ssa.c (non_rewritable_mem_ref_base): Handle TARGET_MEM_REF bases as never rewritable. * gimple-walk.c (walk_stmt_load_store_addr_ops): Do not walk TARGET_MEM_REF bases as address-takens. * tree-ssa-dce.c (ref_may_be_aliased): Handle TARGET_MEM_REF. Diff: --- gcc/cfgexpand.c | 10 ++++++---- gcc/gimple-walk.c | 8 -------- gcc/tree-ssa-dce.c | 2 +- gcc/tree-ssa-operands.c | 4 +++- gcc/tree-ssa.c | 10 ++++++++++ 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 3e6f7cafc4c..39e5b040427 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -6280,10 +6280,12 @@ discover_nonconstant_array_refs_r (tree * tp, int *walk_subtrees, } /* References of size POLY_INT_CST to a fixed-size object must go through memory. It's more efficient to force that here than - to create temporary slots on the fly. */ - else if ((TREE_CODE (t) == MEM_REF || TREE_CODE (t) == TARGET_MEM_REF) - && TYPE_SIZE (TREE_TYPE (t)) - && POLY_INT_CST_P (TYPE_SIZE (TREE_TYPE (t)))) + to create temporary slots on the fly. + RTL expansion expectes TARGET_MEM_REF to always address actual memory. */ + else if (TREE_CODE (t) == TARGET_MEM_REF + || (TREE_CODE (t) == MEM_REF + && TYPE_SIZE (TREE_TYPE (t)) + && POLY_INT_CST_P (TYPE_SIZE (TREE_TYPE (t))))) { tree base = get_base_address (t); if (base diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c index f8b0482564b..e4a55f1eeb6 100644 --- a/gcc/gimple-walk.c +++ b/gcc/gimple-walk.c @@ -748,10 +748,6 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, { if (TREE_CODE (rhs) == ADDR_EXPR) ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), arg, data); - else if (TREE_CODE (rhs) == TARGET_MEM_REF - && TREE_CODE (TMR_BASE (rhs)) == ADDR_EXPR) - ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (rhs), 0), arg, - data); else if (TREE_CODE (rhs) == OBJ_TYPE_REF && TREE_CODE (OBJ_TYPE_REF_OBJECT (rhs)) == ADDR_EXPR) ret |= visit_addr (stmt, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (rhs), @@ -770,10 +766,6 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (val), 0), arg, data); } - lhs = gimple_assign_lhs (stmt); - if (TREE_CODE (lhs) == TARGET_MEM_REF - && TREE_CODE (TMR_BASE (lhs)) == ADDR_EXPR) - ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (lhs), 0), lhs, data); } if (visit_load) { diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index c091868a313..def6ae69e24 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -452,7 +452,7 @@ ref_may_be_aliased (tree ref) gcc_assert (TREE_CODE (ref) != WITH_SIZE_EXPR); while (handled_component_p (ref)) ref = TREE_OPERAND (ref, 0); - if (TREE_CODE (ref) == MEM_REF + if ((TREE_CODE (ref) == MEM_REF || TREE_CODE (ref) == TARGET_MEM_REF) && TREE_CODE (TREE_OPERAND (ref, 0)) == ADDR_EXPR) ref = TREE_OPERAND (TREE_OPERAND (ref, 0), 0); return !(DECL_P (ref) diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index 2fc74d51917..c15575416dd 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -669,7 +669,9 @@ operands_scanner::get_tmr_operands(tree expr, int flags) gimple_set_has_volatile_ops (stmt, true); /* First record the real operands. */ - get_expr_operands (&TMR_BASE (expr), opf_use | (flags & opf_no_vops)); + get_expr_operands (&TMR_BASE (expr), + opf_non_addressable | opf_use + | (flags & (opf_no_vops|opf_not_non_addressable))); get_expr_operands (&TMR_INDEX (expr), opf_use | (flags & opf_no_vops)); get_expr_operands (&TMR_INDEX2 (expr), opf_use | (flags & opf_no_vops)); diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index cf54c891426..4cc400d3c2e 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1494,6 +1494,16 @@ non_rewritable_mem_ref_base (tree ref) return decl; } + /* We cannot rewrite TARGET_MEM_REFs. */ + if (TREE_CODE (base) == TARGET_MEM_REF + && TREE_CODE (TREE_OPERAND (base, 0)) == ADDR_EXPR) + { + tree decl = TREE_OPERAND (TREE_OPERAND (base, 0), 0); + if (! DECL_P (decl)) + return NULL_TREE; + return decl; + } + return NULL_TREE; }
reply other threads:[~2021-05-19 12:54 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210519125409.22ECB393A400@sourceware.org \ --to=rguenth@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).