I am currently testing the following patch enabling us to optimize

void
test (int *a, int *b, int * restrict v)
{
        *a = *v;
        *b = *v;
}
there is a simple case we can handle without implementing ??? from
visit_loadstore.

Richard.

2015-09-23  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/48885
        * tree-ssa-structalias.c (visit_loadstore): Handle default defs
        as not including any restrict tags from other pointers.

        * gcc.dg/tree-ssa/restrict-6.c: New testcase.

Index: gcc/tree-ssa-structalias.c
===================================================================
*** gcc/tree-ssa-structalias.c  (revision 228037)
--- gcc/tree-ssa-structalias.c  (working copy)
*************** visit_loadstore (gimple *, tree base, tr
*** 6952,6961 ****
        || TREE_CODE (base) == TARGET_MEM_REF)
      {
        tree ptr = TREE_OPERAND (base, 0);
!       if (TREE_CODE (ptr) == SSA_NAME)
        {
          /* ???  We need to make sure 'ptr' doesn't include any of
!            the restrict tags in its points-to set.  */
          return false;
        }
  
--- 7047,7057 ----
        || TREE_CODE (base) == TARGET_MEM_REF)
      {
        tree ptr = TREE_OPERAND (base, 0);
!       if (TREE_CODE (ptr) == SSA_NAME
!         && ! SSA_NAME_IS_DEFAULT_DEF (ptr))
        {
          /* ???  We need to make sure 'ptr' doesn't include any of
!            the restrict tags we added bases for in its points-to set.  */
          return false;
        }
  
Index: gcc/testsuite/gcc.dg/tree-ssa/restrict-6.c
===================================================================
*** gcc/testsuite/gcc.dg/tree-ssa/restrict-6.c  (revision 0)
--- gcc/testsuite/gcc.dg/tree-ssa/restrict-6.c  (working copy)
***************
*** 0 ****
--- 1,11 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O -fdump-tree-fre1" } */
+ 
+ void
+ test (int *a, int *b, int * __restrict__ v)
+ {
+   *a = *v;
+   *b = *v;
+ }
+ 
+ /* { dg-final { scan-tree-dump-times "= \\*v" 1 "fre1" } } */

Reply via email to