* Make it cheaper to test whether an SSA name is a virtual operand
@ 2016-12-23 17:50 Richard Sandiford
2016-12-23 20:12 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2016-12-23 17:50 UTC (permalink / raw)
To: gcc-patches
virtual_operand_p handled SSA names by looking at the flags of the
underlying variable. This seems to be a relatively common source
of cache misses, mainly because virtual_operand_p is the first thing
tested by is_gimple_reg.
This patch caches the information in the SSA name itself. Several
flags seem to be free so the patch arbitrarily uses public_flag.
Tested on aarch64-linux-gnu and x86_64-linux-gnu. It improves
compile time by a small (<1%) but reproducable amount on the
tests I've tried. OK to install?
Thanks,
Richard
gcc/
* tree-core.h (tree_base): Document the meaning of public_flag
for SSA names.
* tree.h (SSA_NAME_IS_VIRTUAL_OPERAND): New macro.
(SET_SSA_NAME_VAR_OR_IDENTIFIER): Record whether the variable
is a virtual operand.
* gimple-expr.h (virtual_operand_p): Use SSA_NAME_IS_VIRTUAL_OPERAND.
diff --git a/gcc/gimple-expr.h b/gcc/gimple-expr.h
index f2ccd29..faf4c53 100644
--- a/gcc/gimple-expr.h
+++ b/gcc/gimple-expr.h
@@ -105,11 +105,7 @@ static inline bool
virtual_operand_p (tree op)
{
if (TREE_CODE (op) == SSA_NAME)
- {
- op = SSA_NAME_VAR (op);
- if (!op)
- return false;
- }
+ return SSA_NAME_IS_VIRTUAL_OPERAND (op);
if (TREE_CODE (op) == VAR_DECL)
return VAR_DECL_IS_VIRTUAL_OPERAND (op);
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index eec2d4f3..59d771c 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -1091,6 +1091,9 @@ struct GTY(()) tree_base {
FALLTHROUGH_LABEL_P in
LABEL_DECL
+ SSA_NAME_IS_VIRTUAL_OPERAND in
+ SSA_NAME
+
private_flag:
TREE_PRIVATE in
diff --git a/gcc/tree.h b/gcc/tree.h
index 62cd7bb..e994e93 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1665,6 +1665,11 @@ extern void protected_set_expr_location (tree, location_t);
/* SSA_NAME accessors. */
+/* Whether SSA_NAME NODE is a virtual operand. This simply caches the
+ information in the underlying SSA_NAME_VAR for efficiency. */
+#define SSA_NAME_IS_VIRTUAL_OPERAND(NODE) \
+ SSA_NAME_CHECK (NODE)->base.public_flag
+
/* Returns the IDENTIFIER_NODE giving the SSA name a name or NULL_TREE
if there is no name associated with it. */
#define SSA_NAME_IDENTIFIER(NODE) \
@@ -1683,7 +1688,16 @@ extern void protected_set_expr_location (tree, location_t);
? NULL_TREE : (NODE)->ssa_name.var)
#define SET_SSA_NAME_VAR_OR_IDENTIFIER(NODE,VAR) \
- do { SSA_NAME_CHECK (NODE)->ssa_name.var = (VAR); } while (0)
+ do \
+ { \
+ tree var_ = (VAR); \
+ SSA_NAME_CHECK (NODE)->ssa_name.var = var_; \
+ SSA_NAME_IS_VIRTUAL_OPERAND (NODE) \
+ = (var_ \
+ && TREE_CODE (var_) == VAR_DECL \
+ && VAR_DECL_IS_VIRTUAL_OPERAND (var_)); \
+ } \
+ while (0)
/* Returns the statement which defines this SSA name. */
#define SSA_NAME_DEF_STMT(NODE) SSA_NAME_CHECK (NODE)->ssa_name.def_stmt
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Make it cheaper to test whether an SSA name is a virtual operand
2016-12-23 17:50 Make it cheaper to test whether an SSA name is a virtual operand Richard Sandiford
@ 2016-12-23 20:12 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-12-23 20:12 UTC (permalink / raw)
To: Richard Sandiford, gcc-patches
On December 23, 2016 6:47:37 PM GMT+01:00, Richard Sandiford <richard.sandiford@arm.com> wrote:
>virtual_operand_p handled SSA names by looking at the flags of the
>underlying variable. This seems to be a relatively common source
>of cache misses, mainly because virtual_operand_p is the first thing
>tested by is_gimple_reg.
>
>This patch caches the information in the SSA name itself. Several
>flags seem to be free so the patch arbitrarily uses public_flag.
>
>Tested on aarch64-linux-gnu and x86_64-linux-gnu. It improves
>compile time by a small (<1%) but reproducable amount on the
>tests I've tried. OK to install?
OK.
Richard.
>Thanks,
>Richard
>
>
>gcc/
> * tree-core.h (tree_base): Document the meaning of public_flag
> for SSA names.
> * tree.h (SSA_NAME_IS_VIRTUAL_OPERAND): New macro.
> (SET_SSA_NAME_VAR_OR_IDENTIFIER): Record whether the variable
> is a virtual operand.
> * gimple-expr.h (virtual_operand_p): Use SSA_NAME_IS_VIRTUAL_OPERAND.
>
>diff --git a/gcc/gimple-expr.h b/gcc/gimple-expr.h
>index f2ccd29..faf4c53 100644
>--- a/gcc/gimple-expr.h
>+++ b/gcc/gimple-expr.h
>@@ -105,11 +105,7 @@ static inline bool
> virtual_operand_p (tree op)
> {
> if (TREE_CODE (op) == SSA_NAME)
>- {
>- op = SSA_NAME_VAR (op);
>- if (!op)
>- return false;
>- }
>+ return SSA_NAME_IS_VIRTUAL_OPERAND (op);
>
> if (TREE_CODE (op) == VAR_DECL)
> return VAR_DECL_IS_VIRTUAL_OPERAND (op);
>diff --git a/gcc/tree-core.h b/gcc/tree-core.h
>index eec2d4f3..59d771c 100644
>--- a/gcc/tree-core.h
>+++ b/gcc/tree-core.h
>@@ -1091,6 +1091,9 @@ struct GTY(()) tree_base {
> FALLTHROUGH_LABEL_P in
> LABEL_DECL
>
>+ SSA_NAME_IS_VIRTUAL_OPERAND in
>+ SSA_NAME
>+
> private_flag:
>
> TREE_PRIVATE in
>diff --git a/gcc/tree.h b/gcc/tree.h
>index 62cd7bb..e994e93 100644
>--- a/gcc/tree.h
>+++ b/gcc/tree.h
>@@ -1665,6 +1665,11 @@ extern void protected_set_expr_location (tree,
>location_t);
>
> /* SSA_NAME accessors. */
>
>+/* Whether SSA_NAME NODE is a virtual operand. This simply caches the
>+ information in the underlying SSA_NAME_VAR for efficiency. */
>+#define SSA_NAME_IS_VIRTUAL_OPERAND(NODE) \
>+ SSA_NAME_CHECK (NODE)->base.public_flag
>+
> /* Returns the IDENTIFIER_NODE giving the SSA name a name or NULL_TREE
> if there is no name associated with it. */
> #define SSA_NAME_IDENTIFIER(NODE) \
>@@ -1683,7 +1688,16 @@ extern void protected_set_expr_location (tree,
>location_t);
> ? NULL_TREE : (NODE)->ssa_name.var)
>
> #define SET_SSA_NAME_VAR_OR_IDENTIFIER(NODE,VAR) \
>- do { SSA_NAME_CHECK (NODE)->ssa_name.var = (VAR); } while (0)
>+ do \
>+ { \
>+ tree var_ = (VAR); \
>+ SSA_NAME_CHECK (NODE)->ssa_name.var = var_; \
>+ SSA_NAME_IS_VIRTUAL_OPERAND (NODE) \
>+ = (var_ \
>+ && TREE_CODE (var_) == VAR_DECL \
>+ && VAR_DECL_IS_VIRTUAL_OPERAND (var_)); \
>+ } \
>+ while (0)
>
> /* Returns the statement which defines this SSA name. */
>#define SSA_NAME_DEF_STMT(NODE) SSA_NAME_CHECK
>(NODE)->ssa_name.def_stmt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-23 19:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-23 17:50 Make it cheaper to test whether an SSA name is a virtual operand Richard Sandiford
2016-12-23 20:12 ` Richard Biener
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).