re PR tree-optimization/34011 (Memory load is not eliminated from tight vectorized...
authorRichard Guenther <rguenther@suse.de>
Wed, 16 Sep 2009 08:50:46 +0000 (08:50 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 16 Sep 2009 08:50:46 +0000 (08:50 +0000)
2009-09-16  Richard Guenther  <rguenther@suse.de>

PR middle-end/34011
* tree-flow-inline.h (may_be_aliased): Compute readonly variables
as non-aliased.

* gcc.dg/tree-ssa/ssa-lim-7.c: New testcase.

From-SVN: r151740

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-7.c [new file with mode: 0644]
gcc/tree-flow-inline.h

index 8eca8ba..00f964e 100644 (file)
@@ -1,3 +1,9 @@
+2009-09-16  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/34011
+       * tree-flow-inline.h (may_be_aliased): Compute readonly variables
+       as non-aliased.
+
 2009-09-16  DJ Delorie  <dj@redhat.com>
            Kaz Kojima  <kkojima@gcc.gnu.org>
 
index 1f8eb2e..f2ba973 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-16  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/34011
+       * gcc.dg/tree-ssa/ssa-lim-7.c: New testcase.
+
 2009-09-16  DJ Delorie  <dj@redhat.com>
            Kaz Kojima  <kkojima@gcc.gnu.org>
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-7.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-7.c
new file mode 100644 (file)
index 0000000..f8e15f3
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-lim1-details" } */
+
+extern const int srcshift;
+
+void foo (int *srcdata, int *dstdata)
+{
+  int i;
+
+  for (i = 0; i < 256; i++)
+    dstdata[i] = srcdata[i] << srcshift;
+}
+
+/* { dg-final { scan-tree-dump "Moving statement" "lim1" } } */
+/* { dg-final { cleanup-tree-dump "lim1" } } */
index eef2f43..fdb3337 100644 (file)
@@ -616,12 +616,18 @@ is_global_var (const_tree t)
 
 /* Return true if VAR may be aliased.  A variable is considered as
    maybe aliased if it has its address taken by the local TU
-   or possibly by another TU.  */
+   or possibly by another TU and might be modified through a pointer.  */
 
 static inline bool
 may_be_aliased (const_tree var)
 {
-  return (TREE_PUBLIC (var) || DECL_EXTERNAL (var) || TREE_ADDRESSABLE (var));
+  return (TREE_CODE (var) != CONST_DECL
+         && !((TREE_STATIC (var) || TREE_PUBLIC (var) || DECL_EXTERNAL (var))
+              && TREE_READONLY (var)
+              && !TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (var)))
+         && (TREE_PUBLIC (var)
+             || DECL_EXTERNAL (var)
+             || TREE_ADDRESSABLE (var)));
 }