Let ldist ignore clobbers
authorMarc Glisse <marc.glisse@inria.fr>
Fri, 3 May 2019 13:41:36 +0000 (15:41 +0200)
committerMarc Glisse <glisse@gcc.gnu.org>
Fri, 3 May 2019 13:41:36 +0000 (13:41 +0000)
2019-05-03  Marc Glisse  <marc.glisse@inria.fr>

PR tree-optimization/90269
gcc/
* tree-loop-distribution.c (find_seed_stmts_for_distribution):
Ignore clobbers.

gcc/testsuite/
* g++.dg/tree-ssa/ldist-1.C: New file.

From-SVN: r270852

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/ldist-1.C [new file with mode: 0644]
gcc/tree-loop-distribution.c

index ac134c60419c13bc927b84a8367d13eb0e3f7703..a1f23567ebcacd7adc6afbb07109bb5191c9ee8d 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-03  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR tree-optimization/90269
+       * tree-loop-distribution.c (find_seed_stmts_for_distribution):
+       Ignore clobbers.
+
 2019-05-03  Martin Liska  <mliska@suse.cz>
 
        * hash-map.h: Add is_empty function.
index 7ae100f4fb267cefbcfcc7645bf5d8b6d43e79c5..7dbb8503981dec68b95a427dfa263636e05973f0 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-03  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR tree-optimization/90269
+       * g++.dg/tree-ssa/ldist-1.C: New file.
+
 2019-05-03  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/vect/slp-reduc-sad-2.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/tree-ssa/ldist-1.C b/gcc/testsuite/g++.dg/tree-ssa/ldist-1.C
new file mode 100644 (file)
index 0000000..0fc6a61
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-ldist-details" } */
+
+#include <new>
+struct T {
+    int* p;
+    T(T const&t):p(t.p){}
+};
+void f(T*__restrict a,T*__restrict b){
+    for(int i=0;i<1024;++i){
+       new(a+i)T(b[i]);
+       b[i].~T();
+    }
+}
+
+/* { dg-final { scan-tree-dump "generated memcpy" "ldist" } } */
index 8959f52a67b2bc12e787f1c70b6293cb31961416..3d8f13c4d14b21062c93f3e83c20798762b9ba4d 100644 (file)
@@ -3040,6 +3040,10 @@ find_seed_stmts_for_distribution (struct loop *loop, vec<gimple *> *work_list)
        {
          gimple *stmt = gsi_stmt (gsi);
 
+         /* Ignore clobbers, they do not have true side effects.  */
+         if (gimple_clobber_p (stmt))
+           continue;
+
          /* If there is a stmt with side-effects bail out - we
             cannot and should not distribute this loop.  */
          if (gimple_has_side_effects (stmt))