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

Richard.

2012-05-21  Richard Guenther  <rguent...@suse.de>

        * tree-loop-distribution.c (can_generate_builtin): Reject
        volatile stmts.

        * gcc.dg/torture/ldist-1.c: New testcase.

Index: gcc/tree-loop-distribution.c
===================================================================
*** gcc/tree-loop-distribution.c        (revision 187704)
--- gcc/tree-loop-distribution.c        (working copy)
*************** can_generate_builtin (struct graph *rdg,
*** 822,829 ****
        nb_reads++;
      else if (RDG_MEM_WRITE_STMT (rdg, i))
        {
        nb_writes++;
!       if (stmt_with_adjacent_zero_store_dr_p (RDG_STMT (rdg, i)))
          stores_zero++;
        }
  
--- 822,831 ----
        nb_reads++;
      else if (RDG_MEM_WRITE_STMT (rdg, i))
        {
+       gimple stmt = RDG_STMT (rdg, i);
        nb_writes++;
!       if (!gimple_has_volatile_ops (stmt)
!           && stmt_with_adjacent_zero_store_dr_p (stmt))
          stores_zero++;
        }
  
Index: gcc/testsuite/gcc.dg/torture/ldist-1.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/ldist-1.c      (revision 0)
--- gcc/testsuite/gcc.dg/torture/ldist-1.c      (revision 0)
***************
*** 0 ****
--- 1,12 ----
+ /* { dg-do compile } */
+ /* { dg-options "-ftree-loop-distribute-patterns" } */
+ 
+ void foo (volatile int *p, int n)
+ {
+   int i;
+   for (i = 0; i < n; ++i)
+     p[i] = 0;
+ }
+ 
+ /* { dg-final { scan-assembler-not "memset" } } */
+ /* { dg-final { cleanup-tree-dump "ldist" } } */

Reply via email to