From 9968d233b33186f70cbf9b265ec15b8b97153128 Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Wed, 18 Mar 2009 16:59:55 +0000 Subject: [PATCH] graphite.c (exclude_component_ref): Renamed contains_component_ref_p. 2009-03-18 Sebastian Pop * 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. From-SVN: r144937 --- gcc/ChangeLog | 9 ++++ gcc/graphite.c | 33 +++++++-------- gcc/testsuite/ChangeLog | 7 ++++ gcc/testsuite/g++.dg/graphite/graphite.exp | 48 ++++++++++++++++++++++ gcc/testsuite/g++.dg/graphite/pr39447.C | 34 +++++++++++++++ gcc/tree-vrp.c | 8 ++-- 6 files changed, 116 insertions(+), 23 deletions(-) create mode 100644 gcc/testsuite/g++.dg/graphite/graphite.exp create mode 100644 gcc/testsuite/g++.dg/graphite/pr39447.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 23cb6f8d3dfb..e18131d3d2db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2009-03-18 Sebastian Pop + + 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 * tree-vect-transform.c (vect_loop_versioning): Fold the diff --git a/gcc/graphite.c b/gcc/graphite.c index 58b67f4255af..b732b40d2140 100644 --- a/gcc/graphite.c +++ b/gcc/graphite.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c9d0832fbc35..510ffbff1b56 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2009-03-18 Sebastian Pop + + 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 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 index 000000000000..d1993a2e805f --- /dev/null +++ b/gcc/testsuite/g++.dg/graphite/graphite.exp @@ -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 +# . + +# 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 index 000000000000..a0d09ec2b93c --- /dev/null +++ b/gcc/testsuite/g++.dg/graphite/pr39447.C @@ -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; +} + + diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 77fff6cf8c2b..755b117e54ae 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -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)); } -- 2.39.2