builtin-attrs.def (ATTR_NOVOPS, [...]): New.
authorZdenek Dvorak <dvorakz@suse.cz>
Mon, 14 Mar 2005 16:21:16 +0000 (17:21 +0100)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Mon, 14 Mar 2005 16:21:16 +0000 (16:21 +0000)
* builtin-attrs.def (ATTR_NOVOPS, ATTR_NOVOPS_LIST,
ATTR_PURE_NOTHROW_NOVOPS_LIST): New.
* builtins.def (ATTR_MATHFN_FPROUNDING): Use NOVOPS.
(BUILT_IN_PREFETCH): Set the NOVOPS attribute.
* c-common.c (handle_novops_attribute): New function.
(c_common_attribute_table): Add "no vops" entry.
* c-decl.c (merge_decls): Copy DECL_IS_NOVOPS.
* calls.c (flags_from_decl_or_type): Set ECF_NOVOPS.
* tree-ssa-operands.c (get_call_expr_operands): Do not
create virtual operands for calls with ECF_NOVOPS flag.
* tree.h (DECL_IS_NOVOPS): New macro.
(struct tree_decl): Add novops_flag.
(ECF_NOVOPS): New constant.

From-SVN: r96438

gcc/ChangeLog
gcc/builtin-attrs.def
gcc/builtins.def
gcc/c-common.c
gcc/c-decl.c
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/20050314-1.c [new file with mode: 0644]
gcc/tree-ssa-operands.c
gcc/tree.h

index 04024683b7a53638ae566947ce34f8f45bb4a59a..0d01767f7dd265a473da18ed7d3d73ed61cfdf37 100644 (file)
@@ -1,3 +1,19 @@
+2005-03-14  Zdenek Dvorak  <dvorakz@suse.cz>
+
+       * builtin-attrs.def (ATTR_NOVOPS, ATTR_NOVOPS_LIST,
+       ATTR_PURE_NOTHROW_NOVOPS_LIST): New.
+       * builtins.def (ATTR_MATHFN_FPROUNDING): Use NOVOPS.
+       (BUILT_IN_PREFETCH): Set the NOVOPS attribute.
+       * c-common.c (handle_novops_attribute): New function.
+       (c_common_attribute_table): Add "no vops" entry.
+       * c-decl.c (merge_decls): Copy DECL_IS_NOVOPS.
+       * calls.c (flags_from_decl_or_type): Set ECF_NOVOPS.
+       * tree-ssa-operands.c (get_call_expr_operands): Do not
+       create virtual operands for calls with ECF_NOVOPS flag.
+       * tree.h (DECL_IS_NOVOPS): New macro.
+       (struct tree_decl): Add novops_flag.
+       (ECF_NOVOPS): New constant.
+
 2005-03-14  Uros Bizjak  <uros@kss-loka.si>
 
        PR target/17688
index bfb70521bf2f935aac1173caddb9de44e1908499..971723de695f56ec58d8cfd7e52604010aa6ac3f 100644 (file)
@@ -83,17 +83,22 @@ DEF_ATTR_IDENT (ATTR_GCC_DIAG, "gcc_diag")
 DEF_ATTR_IDENT (ATTR_GCC_CDIAG, "gcc_cdiag")
 DEF_ATTR_IDENT (ATTR_GCC_CXXDIAG, "gcc_cxxdiag")
 DEF_ATTR_IDENT (ATTR_PURE, "pure")
+DEF_ATTR_IDENT (ATTR_NOVOPS, "no vops")
 DEF_ATTR_IDENT (ATTR_SCANF, "scanf")
 DEF_ATTR_IDENT (ATTR_SENTINEL, "sentinel")
 DEF_ATTR_IDENT (ATTR_STRFMON, "strfmon")
 DEF_ATTR_IDENT (ATTR_STRFTIME, "strftime")
 
+DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LIST, ATTR_NOVOPS, ATTR_NULL, ATTR_NULL)
+
 DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LIST, ATTR_NOTHROW, ATTR_NULL, ATTR_NULL)
 
 DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LIST, ATTR_CONST,       \
                        ATTR_NULL, ATTR_NOTHROW_LIST)
 DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LIST, ATTR_PURE,         \
                        ATTR_NULL, ATTR_NOTHROW_LIST)
+DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NOVOPS_LIST, ATTR_NOVOPS,        \
+                       ATTR_NULL, ATTR_PURE_NOTHROW_LIST)
 DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN, \
                        ATTR_NULL, ATTR_NOTHROW_LIST)
 DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC,     \
index 33617c493b65ac8ce400f4c62be09ba612d06b35..d324e01a584a02c13a8e47461fe4240e75f8d69c 100644 (file)
@@ -134,7 +134,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    global memory.  In "unsafe" mode we can be less careful.  */
 #undef ATTR_MATHFN_FPROUNDING
 #define ATTR_MATHFN_FPROUNDING (flag_unsafe_math_optimizations ? \
-       ATTR_CONST_NOTHROW_LIST : ATTR_PURE_NOTHROW_LIST)
+       ATTR_CONST_NOTHROW_LIST : ATTR_PURE_NOTHROW_NOVOPS_LIST)
 
 /* Define an attribute list for math functions that are normally
    "impure" because some of them may write into global memory for
@@ -612,7 +612,7 @@ DEF_GCC_BUILTIN        (BUILT_IN_POPCOUNT, "popcount", BT_FN_INT_UINT, ATTR_CONS
 DEF_GCC_BUILTIN        (BUILT_IN_POPCOUNTIMAX, "popcountimax", BT_FN_INT_UINTMAX, ATTR_CONST_NOTHROW_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_POPCOUNTL, "popcountl", BT_FN_INT_ULONG, ATTR_CONST_NOTHROW_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_POPCOUNTLL, "popcountll", BT_FN_INT_ULONGLONG, ATTR_CONST_NOTHROW_LIST)
-DEF_GCC_BUILTIN        (BUILT_IN_PREFETCH, "prefetch", BT_FN_VOID_CONST_PTR_VAR, ATTR_NULL)
+DEF_GCC_BUILTIN        (BUILT_IN_PREFETCH, "prefetch", BT_FN_VOID_CONST_PTR_VAR, ATTR_NOVOPS_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_RETURN, "return", BT_FN_VOID_PTR, ATTR_NORETURN_NOTHROW_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_RETURN_ADDRESS, "return_address", BT_FN_PTR_UINT, ATTR_NULL)
 DEF_GCC_BUILTIN        (BUILT_IN_SAVEREGS, "saveregs", BT_FN_PTR_VAR, ATTR_NULL)
index d26c8b1452d75845fdd7b0f0651482f6b0fd7d27..313b554249de2d2bac83a1250a32ebf28f51d821 100644 (file)
@@ -541,6 +541,7 @@ static tree handle_returns_twice_attribute (tree *, tree, tree, int, bool *);
 static tree handle_no_limit_stack_attribute (tree *, tree, tree, int,
                                             bool *);
 static tree handle_pure_attribute (tree *, tree, tree, int, bool *);
+static tree handle_novops_attribute (tree *, tree, tree, int, bool *);
 static tree handle_deprecated_attribute (tree *, tree, tree, int,
                                         bool *);
 static tree handle_vector_size_attribute (tree *, tree, tree, int,
@@ -614,6 +615,10 @@ const struct attribute_spec c_common_attribute_table[] =
                              handle_no_limit_stack_attribute },
   { "pure",                   0, 0, true,  false, false,
                              handle_pure_attribute },
+  /* For internal use (marking of builtins) only.  The name contains space
+     to prevent its usage in source code.  */
+  { "no vops",                0, 0, true,  false, false,
+                             handle_novops_attribute },
   { "deprecated",             0, 0, false, false, false,
                              handle_deprecated_attribute },
   { "vector_size",           1, 1, false, true, false,
@@ -4854,6 +4859,19 @@ handle_pure_attribute (tree *node, tree name, tree ARG_UNUSED (args),
   return NULL_TREE;
 }
 
+/* Handle a "no vops" attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_novops_attribute (tree *node, tree ARG_UNUSED (name),
+                        tree ARG_UNUSED (args), int ARG_UNUSED (flags),
+                        bool *ARG_UNUSED (no_add_attrs))
+{
+  gcc_assert (TREE_CODE (*node) == FUNCTION_DECL);
+  DECL_IS_NOVOPS (*node) = 1;
+  return NULL_TREE;
+}
+
 /* Handle a "deprecated" attribute; arguments as in
    struct attribute_spec.handler.  */
 
index 400c6cf293b580d08bc2140bc8800e636ab3451d..eee7b66a7b5a29b3eb51684fa7f61a1c95cc6122 100644 (file)
@@ -1689,6 +1689,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
       TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
       DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
       DECL_IS_PURE (newdecl) |= DECL_IS_PURE (olddecl);
+      DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl);
     }
 
   /* Merge the storage class information.  */
index d6032fc78bcac4b1cc34bcce2753d2087c7a3448..4b9e051298dc8716adbdb1f9598639dcfe13a642 100644 (file)
@@ -593,6 +593,9 @@ flags_from_decl_or_type (tree exp)
       if (DECL_IS_PURE (exp))
        flags |= ECF_PURE | ECF_LIBCALL_BLOCK;
 
+      if (DECL_IS_NOVOPS (exp))
+       flags |= ECF_NOVOPS;
+
       if (TREE_NOTHROW (exp))
        flags |= ECF_NOTHROW;
 
index 841c7330a6cb64801fd73a307442f9647ec81b40..24dc38a4accf83ac80a4a7c2d8dfcec49e863247 100644 (file)
@@ -1,3 +1,7 @@
+2005-03-14  Zdenek Dvorak  <dvorakz@suse.cz>
+
+       * gcc.dg/tree-ssa/20050314-1.c: New test.
+
 2005-03-14  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/4403
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20050314-1.c b/gcc/testsuite/gcc.dg/tree-ssa/20050314-1.c
new file mode 100644 (file)
index 0000000..3f8cfb3
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-lim-details" } */
+
+float a[100];
+
+int foo(void);
+float sinf (float);
+
+void xxx (void)
+{
+  int i, k = foo ();
+
+  for (i = 0; i < 100; i++)
+    a[k] += sinf (i);
+}
+
+/* Store motion may be applied to the assignment to a[k], since sinf
+   cannot read nor write the memory.  */
+
+/* { dg-final { scan-tree-dump-times "Moving statement" 1 "lim" } } */
+
index 8db74e1fadb85416b36958bfb1630e772821cc35..2a63d0874a67322c81382070a8376c5386c980b5 100644 (file)
@@ -1529,7 +1529,9 @@ get_call_expr_operands (tree stmt, tree expr)
      computed.  By not bothering with virtual operands for CALL_EXPRs
      we avoid adding superfluous virtual operands, which can be a
      significant compile time sink (See PR 15855).  */
-  if (aliases_computed_p && !bitmap_empty_p (call_clobbered_vars))
+  if (aliases_computed_p
+      && !bitmap_empty_p (call_clobbered_vars)
+      && !(call_flags & ECF_NOVOPS))
     {
       /* A 'pure' or a 'const' functions never call clobber anything. 
         A 'noreturn' function might, but since we don't return anyway 
index 3857ff909cc1fdbdc725224c4c4a27c269e8da51..8854b7df8fdff3b38bb92dfc03a80ae921c2bbd5 100644 (file)
@@ -2185,6 +2185,11 @@ struct tree_binfo GTY (())
    as "pure" function (like const function, but may read global memory).  */
 #define DECL_IS_PURE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.pure_flag)
 
+/* Nonzero in a FUNCTION_DECL means this function should be treated
+   as "novops" function (function that does not read global memory,
+   but may have arbitrary side effects).  */
+#define DECL_IS_NOVOPS(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.novops_flag)
+     
 /* Nonzero in a FIELD_DECL means it is a bit field, and must be accessed
    specially.  */
 #define DECL_BIT_FIELD(NODE) (FIELD_DECL_CHECK (NODE)->decl.bit_field_flag)
@@ -2365,7 +2370,6 @@ struct tree_decl GTY(())
   unsigned uninlinable : 1;
   unsigned thread_local_flag : 1;
   unsigned declared_inline_flag : 1;
-  unsigned seen_in_bind_expr : 1;
   ENUM_BITFIELD(symbol_visibility) visibility : 2;
   unsigned visibility_specified : 1;
 
@@ -2383,7 +2387,9 @@ struct tree_decl GTY(())
   unsigned gimple_formal_temp : 1;
   unsigned debug_expr_is_from : 1;
   unsigned returns_twice_flag : 1;
-  /* 11 unused bits.  */
+  unsigned seen_in_bind_expr : 1;
+  unsigned novops_flag : 1;
+  /* 9 unused bits.  */
 
   union tree_decl_u1 {
     /* In a FUNCTION_DECL for which DECL_BUILT_IN holds, this is
@@ -3688,6 +3694,9 @@ extern rtx emit_line_note (location_t);
 #define ECF_SP_DEPRESSED       256
 /* Create libcall block around the call.  */
 #define ECF_LIBCALL_BLOCK      512
+/* Function does not read or write memory (but may have side effects, so
+   it does not necessarily fit ECF_CONST).  */
+#define ECF_NOVOPS             1024
 
 extern int flags_from_decl_or_type (tree);
 extern int call_expr_flags (tree);