This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Restore vectorization for testcase in PR34011


Not a real fix for PR34011 but a fix to restore the vectorization
for the testcase therein.  Readonly variables cannot be changed
by any means and so we can safely claim they are not aliased.
In 4.4 and before the operand scanner pruned these aliases.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

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.

Index: gcc/tree-flow-inline.h
===================================================================
*** gcc/tree-flow-inline.h	(revision 151721)
--- gcc/tree-flow-inline.h	(working copy)
*************** is_global_var (const_tree t)
*** 616,627 ****
  
  /* 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.  */
  
  static inline bool
  may_be_aliased (const_tree var)
  {
!   return (TREE_PUBLIC (var) || DECL_EXTERNAL (var) || TREE_ADDRESSABLE (var));
  }
  
  
--- 616,633 ----
  
  /* 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 and might be modified through a pointer.  */
  
  static inline bool
  may_be_aliased (const_tree 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)));
  }
  
  
Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-7.c
===================================================================
*** gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-7.c	(revision 0)
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-7.c	(revision 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]