OSDN Git Service

2009-03-18 Sebastian Pop <sebastian.pop@amd.com>
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Mar 2009 16:59:55 +0000 (16:59 +0000)
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Mar 2009 16:59:55 +0000 (16:59 +0000)
* graphite.c (exclude_component_ref): Renamed contains_component_ref_p.
(is_simple_operand): Call contains_component_ref_p before calling data
reference analysis that would fail on COMPONENT_REFs.

* tree-vrp.c (search_for_addr_array): Fix formatting.

* g++.dg/graphite: New.
* g++.dg/graphite/graphite.exp: New.
* g++.dg/graphite/pr39447.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144937 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/graphite.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/graphite/graphite.exp [new file with mode: 0644]
gcc/testsuite/g++.dg/graphite/pr39447.C [new file with mode: 0644]
gcc/tree-vrp.c

index 23cb6f8..e18131d 100644 (file)
@@ -1,3 +1,12 @@
+2009-03-18  Sebastian Pop  <sebastian.pop@amd.com>
+
+       PR middle-end/39447
+       * graphite.c (exclude_component_ref): Renamed contains_component_ref_p.
+       (is_simple_operand): Call contains_component_ref_p before calling data
+       reference analysis that would fail on COMPONENT_REFs.
+
+       * tree-vrp.c (search_for_addr_array): Fix formatting.
+
 2009-03-18  Richard Guenther  <rguenther@suse.de>
 
        * tree-vect-transform.c (vect_loop_versioning): Fold the
index 58b67f4..b732b40 100644 (file)
@@ -1058,31 +1058,24 @@ loop_affine_expr (basic_block scop_entry, struct loop *loop, tree expr)
          || evolution_function_is_affine_multivariate_p (scev, n));
 }
 
-/* Return false if the tree_code of the operand OP or any of its operands
-   is component_ref.  */
+/* Return true if REF or any of its subtrees contains a
+   component_ref.  */
 
 static bool
-exclude_component_ref (tree op) 
+contains_component_ref_p (tree ref)
 {
-  int i;
-  int len;
+  if (!ref)
+    return false;
 
-  if (op)
+  while (handled_component_p (ref))
     {
-      if (TREE_CODE (op) == COMPONENT_REF)
-       return false;
-      else
-       {
-         len = TREE_OPERAND_LENGTH (op);         
-         for (i = 0; i < len; ++i)
-           {
-             if (!exclude_component_ref (TREE_OPERAND (op, i)))
-               return false;
-           }
-       }
+      if (TREE_CODE (ref) == COMPONENT_REF)
+       return true;
+
+      ref = TREE_OPERAND (ref, 0);
     }
 
-  return true;
+  return false;
 }
 
 /* Return true if the operand OP is simple.  */
@@ -1094,13 +1087,15 @@ is_simple_operand (loop_p loop, gimple stmt, tree op)
   if (DECL_P (op)
       /* or a structure,  */
       || AGGREGATE_TYPE_P (TREE_TYPE (op))
+      /* or a COMPONENT_REF,  */
+      || contains_component_ref_p (op)
       /* or a memory access that cannot be analyzed by the data
         reference analysis.  */
       || ((handled_component_p (op) || INDIRECT_REF_P (op))
          && !stmt_simple_memref_p (loop, stmt, op)))
     return false;
 
-  return exclude_component_ref (op);
+  return true;
 }
 
 /* Return true only when STMT is simple enough for being handled by
index c9d0832..510ffbf 100644 (file)
@@ -1,3 +1,10 @@
+2009-03-18  Sebastian Pop  <sebastian.pop@amd.com>
+
+       PR middle-end/39447
+       * g++.dg/graphite: New.
+       * g++.dg/graphite/graphite.exp: New.
+       * g++.dg/graphite/pr39447.C: New.
+
 2009-03-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR c++/39425
diff --git a/gcc/testsuite/g++.dg/graphite/graphite.exp b/gcc/testsuite/g++.dg/graphite/graphite.exp
new file mode 100644 (file)
index 0000000..d1993a2
--- /dev/null
@@ -0,0 +1,48 @@
+#   Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib g++-dg.exp
+
+if ![check_effective_target_fgraphite] {
+  return
+}
+
+# The default action for a test is 'compile'.  Save current default.
+global dg-do-what-default
+set save-dg-do-what-default ${dg-do-what-default}
+set dg-do-what-default compile
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] \
+       "" $DEFAULT_CFLAGS
+
+# Clean up.
+set dg-do-what-default ${save-dg-do-what-default}
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/g++.dg/graphite/pr39447.C b/gcc/testsuite/g++.dg/graphite/pr39447.C
new file mode 100644 (file)
index 0000000..a0d09ec
--- /dev/null
@@ -0,0 +1,34 @@
+/* { dg-options "-O2 -fgraphite-identity" } */
+
+struct Point
+{
+  int line, col;
+
+  Point( int l = -1, int c = 0 ) throw() : line( l ), col( c ) {}
+  bool operator==( const Point & p ) const throw()
+  { return ( line == p.line && col == p.col ); }
+  bool operator<( const Point & p ) const throw()
+  { return ( line < p.line || ( line == p.line && col < p.col ) ); }
+};
+
+class Buffer
+{
+public:
+  int characters( const int line ) const throw();
+  int pgetc( Point & p ) const throw();
+  Point eof() const throw() { return Point( 0, 0 ); }
+  bool pisvalid( const Point & p ) const throw()
+  { return ( ( p.col >= 0 && p.col < characters( p.line ) ) || p == eof() );
+  }
+  bool save( Point p1 = Point(), Point p2 = Point() ) const;
+};
+
+bool Buffer::save( Point p1, Point p2 ) const
+{
+  if( !this->pisvalid( p1 ) ) p1 = eof();
+  if( !this->pisvalid( p2 ) ) p2 = eof();
+  for( Point p = p1; p < p2; ) { pgetc( p ); }
+  return true;
+}
+
+
index 77fff6c..755b117 100644 (file)
@@ -5067,7 +5067,7 @@ check_array_ref (tree ref, const location_t *location, bool ignore_off_by_one)
    address of an ARRAY_REF, and call check_array_ref on it.  */
 
 static void
-search_for_addr_array(tree t, const location_t *location)
+search_for_addr_array (tree t, const location_t *location)
 {
   while (TREE_CODE (t) == SSA_NAME)
     {
@@ -5076,8 +5076,8 @@ search_for_addr_array(tree t, const location_t *location)
       if (gimple_code (g) != GIMPLE_ASSIGN)
        return;
 
-      if (get_gimple_rhs_class (gimple_assign_rhs_code (g)) !=
-         GIMPLE_SINGLE_RHS)
+      if (get_gimple_rhs_class (gimple_assign_rhs_code (g)) 
+         != GIMPLE_SINGLE_RHS)
        return;
 
       t = gimple_assign_rhs1 (g);
@@ -5094,7 +5094,7 @@ search_for_addr_array(tree t, const location_t *location)
       if (TREE_CODE (t) == ARRAY_REF)
        check_array_ref (t, location, true /*ignore_off_by_one*/);
 
-      t = TREE_OPERAND(t,0);
+      t = TREE_OPERAND (t, 0);
     }
   while (handled_component_p (t));
 }