From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Simplify gimple_assign_load
Date: Fri, 16 Dec 2022 13:33:53 +0000 (UTC) [thread overview]
Message-ID: <20221216133353.QOgqEvFYFhFyz80S6PdF6MxNX7fsCzXWyw13sAnxCQA@z> (raw)
The following simplifies and outlines gimple_assign_load. In
particular it is not necessary to get at the base of the possibly
loaded expression but just handle the case of a single handled
component wrapping a non-memory operand.
Bootstrapped and tested on x86_64-unknown-linux-gnu, not yet
sure if I queue this for stage1 or push it next week.
* gimple.h (gimple_assign_load): Outline...
* gimple.cc (gimple_assign_load): ... here. Avoid
get_base_address and instead just strip the outermost
handled component, treating a remaining handled component
as load.
---
gcc/gimple.cc | 20 ++++++++++++++++++++
gcc/gimple.h | 17 +----------------
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/gcc/gimple.cc b/gcc/gimple.cc
index dd054e16453..e7bb7dd12f6 100644
--- a/gcc/gimple.cc
+++ b/gcc/gimple.cc
@@ -1797,6 +1797,26 @@ gimple_assign_unary_nop_p (gimple *gs)
== TYPE_MODE (TREE_TYPE (gimple_assign_rhs1 (gs)))));
}
+/* Return true if GS is an assignment that loads from its rhs1. */
+
+bool
+gimple_assign_load_p (const gimple *gs)
+{
+ tree rhs;
+ if (!gimple_assign_single_p (gs))
+ return false;
+ rhs = gimple_assign_rhs1 (gs);
+ if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
+ return true;
+ if (handled_component_p (rhs))
+ rhs = TREE_OPERAND (rhs, 0);
+ return (handled_component_p (rhs)
+ || DECL_P (rhs)
+ || TREE_CODE (rhs) == MEM_REF
+ || TREE_CODE (rhs) == TARGET_MEM_REF);
+}
+
+
/* Set BB to be the basic block holding G. */
void
diff --git a/gcc/gimple.h b/gcc/gimple.h
index adbeb063186..b6ece9f409b 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1629,6 +1629,7 @@ tree gimple_call_nonnull_arg (gcall *);
bool gimple_assign_copy_p (gimple *);
bool gimple_assign_ssa_name_copy_p (gimple *);
bool gimple_assign_unary_nop_p (gimple *);
+bool gimple_assign_load_p (const gimple *);
void gimple_set_bb (gimple *, basic_block);
void gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *, tree);
void gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *, enum tree_code,
@@ -2952,22 +2953,6 @@ gimple_store_p (const gimple *gs)
return lhs && !is_gimple_reg (lhs);
}
-/* Return true if GS is an assignment that loads from its rhs1. */
-
-static inline bool
-gimple_assign_load_p (const gimple *gs)
-{
- tree rhs;
- if (!gimple_assign_single_p (gs))
- return false;
- rhs = gimple_assign_rhs1 (gs);
- if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
- return true;
- rhs = get_base_address (rhs);
- return (DECL_P (rhs)
- || TREE_CODE (rhs) == MEM_REF || TREE_CODE (rhs) == TARGET_MEM_REF);
-}
-
/* Return true if S is a type-cast assignment. */
--
2.35.3
next reply other threads:[~2022-12-16 13:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-16 13:33 Richard Biener [this message]
2023-04-19 9:47 Richard Biener
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=20221216133353.QOgqEvFYFhFyz80S6PdF6MxNX7fsCzXWyw13sAnxCQA@z \
--to=rguenther@suse.de \
--cc=gcc-patches@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: link
Be 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).