]> gcc.gnu.org Git - gcc.git/commitdiff
Make it cheaper to test whether an SSA name is a virtual operand
authorRichard Sandiford <richard.sandiford@arm.com>
Sat, 24 Dec 2016 14:30:18 +0000 (14:30 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sat, 24 Dec 2016 14:30:18 +0000 (14:30 +0000)
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.

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.

From-SVN: r243916

gcc/ChangeLog
gcc/gimple-expr.h
gcc/tree-core.h
gcc/tree.h

index 16ca10b945e026ab2796e1f42e732b8b9f630e10..6947477ea53b9635a09835db1491f18477eb01a3 100644 (file)
@@ -1,3 +1,12 @@
+2016-12-24  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * 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.
+
 2016-12-22  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
        * tree-pretty-print.c (dump_generic_node): Change dump format for
index f2ccd29a94a6a36a09ffa947f117d959ada97689..faf4c53db3020a5c241b933f75125bc88acb4fdd 100644 (file)
@@ -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);
index eec2d4f35b5cb053c607f05d9b76b2c7dafc047e..59d771c1713072eeaa9b81e7f06f2596e53786a6 100644 (file)
@@ -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
index e3192027575cdb1dbd834c589c6d7a9b8af53b3e..2dec19e42e618bf7f49ff954875f7613657c8fba 100644 (file)
@@ -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
This page took 0.096302 seconds and 5 git commands to generate.