re PR tree-optimization/88440 (size optimization of memcpy-like code)
authorRichard Biener <rguenther@suse.de>
Thu, 23 May 2019 11:35:16 +0000 (11:35 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 23 May 2019 11:35:16 +0000 (11:35 +0000)
2019-05-23  Richard Biener  <rguenther@suse.de>

PR tree-optimization/88440
* opts.c (default_options_table): Enable -ftree-loop-distribute-patterns
at -O[2s]+.
* tree-loop-distribution.c (generate_memset_builtin): Fold the
generated call.
(generate_memcpy_builtin): Likewise.
(distribute_loop): Pass in whether to only distribute patterns.
(prepare_perfect_loop_nest): Also allow size optimization.
(pass_loop_distribution::execute): When optimizing a loop
nest for size allow pattern replacement.

* gcc.dg/tree-ssa/ldist-37.c: New testcase.
* gcc.dg/tree-ssa/ldist-38.c: Likewise.
* gcc.dg/vect/vect.exp: Add -fno-tree-loop-distribute-patterns.
* gcc.dg/tree-ssa/ldist-37.c: Adjust.
* gcc.dg/tree-ssa/ldist-38.c: Likewise.
* g++.dg/tree-ssa/pr78847.C: Likewise.
* gcc.dg/autopar/pr39500-1.c: Likewise.
* gcc.dg/autopar/reduc-1char.c: Likewise.
* gcc.dg/autopar/reduc-7.c: Likewise.
* gcc.dg/tree-ssa/ivopts-lt-2.c: Likewise.
* gcc.dg/tree-ssa/ivopts-lt.c: Likewise.
* gcc.dg/tree-ssa/predcom-dse-1.c: Likewise.
* gcc.dg/tree-ssa/predcom-dse-2.c: Likewise.
* gcc.dg/tree-ssa/predcom-dse-3.c: Likewise.
* gcc.dg/tree-ssa/predcom-dse-4.c: Likewise.
* gcc.dg/tree-ssa/prefetch-7.c: Likewise.
* gcc.dg/tree-ssa/prefetch-8.c: Likewise.
* gcc.dg/tree-ssa/prefetch-9.c: Likewise.
* gcc.dg/tree-ssa/scev-11.c: Likewise.
* gcc.dg/vect/costmodel/i386/costmodel-vect-31.c: Likewise.
* gcc.dg/vect/costmodel/i386/costmodel-vect-33.c: Likewise.
* gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c: Likewise.
* gcc.dg/vect/costmodel/x86_64/costmodel-vect-33.c: Likewise.
* gcc.target/i386/pr30970.c: Likewise.
* gcc.target/i386/vect-double-1.c: Likewise.
* gcc.target/i386/vect-double-2.c: Likewise.
* gcc.dg/tree-ssa/gen-vect-2.c: Likewise.
* gcc.dg/tree-ssa/gen-vect-26.c: Likewise.
* gcc.dg/tree-ssa/gen-vect-28.c: Likewise.
* gcc.dg/tree-ssa/gen-vect-32.c: Likewise.
* gfortran.dg/vect/vect-5.f90: Likewise.
* gfortran.dg/vect/vect-8.f90: Likewise.

From-SVN: r271553

32 files changed:
gcc/ChangeLog
gcc/opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/pr78847.C
gcc/testsuite/gcc.dg/autopar/pr39500-1.c
gcc/testsuite/gcc.dg/autopar/reduc-1char.c
gcc/testsuite/gcc.dg/autopar/reduc-7.c
gcc/testsuite/gcc.dg/tree-ssa/gen-vect-2.c
gcc/testsuite/gcc.dg/tree-ssa/gen-vect-26.c
gcc/testsuite/gcc.dg/tree-ssa/gen-vect-28.c
gcc/testsuite/gcc.dg/tree-ssa/gen-vect-32.c
gcc/testsuite/gcc.dg/tree-ssa/ivopts-lt-2.c
gcc/testsuite/gcc.dg/tree-ssa/ivopts-lt.c
gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-1.c
gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-2.c
gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-3.c
gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-4.c
gcc/testsuite/gcc.dg/tree-ssa/prefetch-7.c
gcc/testsuite/gcc.dg/tree-ssa/prefetch-8.c
gcc/testsuite/gcc.dg/tree-ssa/prefetch-9.c
gcc/testsuite/gcc.dg/tree-ssa/scev-11.c
gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c
gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-33.c
gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c
gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-33.c
gcc/testsuite/gcc.dg/vect/vect.exp
gcc/testsuite/gcc.target/i386/pr30970.c
gcc/testsuite/gcc.target/i386/vect-double-1.c
gcc/testsuite/gcc.target/i386/vect-double-2.c
gcc/testsuite/gfortran.dg/vect/vect-5.f90
gcc/testsuite/gfortran.dg/vect/vect-8.f90
gcc/tree-loop-distribution.c

index e49c75847f1c618be270a8d46e6914e8e96e6e6f..695f9c4bb60b1dbc8c9414d3195bfce0221b6059 100644 (file)
@@ -1,3 +1,16 @@
+2019-05-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88440
+       * opts.c (default_options_table): Enable -ftree-loop-distribute-patterns
+       at -O[2s]+.
+       * tree-loop-distribution.c (generate_memset_builtin): Fold the
+       generated call.
+       (generate_memcpy_builtin): Likewise.
+       (distribute_loop): Pass in whether to only distribute patterns.
+       (prepare_perfect_loop_nest): Also allow size optimization.
+       (pass_loop_distribution::execute): When optimizing a loop
+       nest for size allow pattern replacement.
+
 2019-05-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/90568
index 879ab17c3620ca6e002b46f4f833ed2b4c0f5432..2e3e8b20537f6b034813bc506e1d6a8d11261f59 100644 (file)
@@ -550,7 +550,7 @@ static const struct default_options default_options_table[] =
     { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
     { OPT_LEVELS_3_PLUS, OPT_fsplit_loops, NULL, 1 },
     { OPT_LEVELS_3_PLUS, OPT_fsplit_paths, NULL, 1 },
-    { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
+    { OPT_LEVELS_2_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
     { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribution, NULL, 1 },
     { OPT_LEVELS_3_PLUS, OPT_ftree_loop_vectorize, NULL, 1 },
     { OPT_LEVELS_3_PLUS, OPT_ftree_partial_pre, NULL, 1 },
index b34d1cc74b4a27dfb840e786e1ee71f750802e7c..01afd3b5b0a838875ba8b8e8d3ca95f942225f47 100644 (file)
@@ -1,3 +1,39 @@
+2019-05-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88440
+       * gcc.dg/tree-ssa/ldist-37.c: New testcase.
+       * gcc.dg/tree-ssa/ldist-38.c: Likewise.
+       * gcc.dg/vect/vect.exp: Add -fno-tree-loop-distribute-patterns.
+       * gcc.dg/tree-ssa/ldist-37.c: Adjust.
+       * gcc.dg/tree-ssa/ldist-38.c: Likewise.
+       * g++.dg/tree-ssa/pr78847.C: Likewise.
+       * gcc.dg/autopar/pr39500-1.c: Likewise.
+       * gcc.dg/autopar/reduc-1char.c: Likewise.
+       * gcc.dg/autopar/reduc-7.c: Likewise.
+       * gcc.dg/tree-ssa/ivopts-lt-2.c: Likewise.
+       * gcc.dg/tree-ssa/ivopts-lt.c: Likewise.
+       * gcc.dg/tree-ssa/predcom-dse-1.c: Likewise.
+       * gcc.dg/tree-ssa/predcom-dse-2.c: Likewise.
+       * gcc.dg/tree-ssa/predcom-dse-3.c: Likewise.
+       * gcc.dg/tree-ssa/predcom-dse-4.c: Likewise.
+       * gcc.dg/tree-ssa/prefetch-7.c: Likewise.
+       * gcc.dg/tree-ssa/prefetch-8.c: Likewise.
+       * gcc.dg/tree-ssa/prefetch-9.c: Likewise.
+       * gcc.dg/tree-ssa/scev-11.c: Likewise.
+       * gcc.dg/vect/costmodel/i386/costmodel-vect-31.c: Likewise.
+       * gcc.dg/vect/costmodel/i386/costmodel-vect-33.c: Likewise.
+       * gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c: Likewise.
+       * gcc.dg/vect/costmodel/x86_64/costmodel-vect-33.c: Likewise.
+       * gcc.target/i386/pr30970.c: Likewise.
+       * gcc.target/i386/vect-double-1.c: Likewise.
+       * gcc.target/i386/vect-double-2.c: Likewise.
+       * gcc.dg/tree-ssa/gen-vect-2.c: Likewise.
+       * gcc.dg/tree-ssa/gen-vect-26.c: Likewise.
+       * gcc.dg/tree-ssa/gen-vect-28.c: Likewise.
+       * gcc.dg/tree-ssa/gen-vect-32.c: Likewise.
+       * gfortran.dg/vect/vect-5.f90: Likewise.
+       * gfortran.dg/vect/vect-8.f90: Likewise.
+
 2019-05-23  Martin Liska  <mliska@suse.cz>
 
        PR sanitizer/90570
index d5a83943804ecd6898fea545bf41ddb35c233e7c..e72e516d8d4b937081ec020ca442a1e10594ab3d 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target c++14 } */
-/* { dg-options "-O3 -fdump-tree-ldist" } */
+/* { dg-options "-O3 -fdump-tree-ldist-optimized" } */
 
 #include <stddef.h>
 #include <cstring>
@@ -23,4 +23,4 @@ void testWithLoopValue(const Foo foo, size_t ptr, char *buf_) {
       buf_[ptr++] = c;
 }
 
-/* { dg-final { scan-tree-dump "memcpy\[^\n\r\]*, 9\\);" "ldist" } } */
+/* { dg-final { scan-tree-dump "split to 0 loops and 1 library calls" "ldist" } } */
index 28f47897b37124240343fbb98a576b873bd10030..80ae92522dbe4f3a3e467f4284f606f9d398dc11 100644 (file)
@@ -1,7 +1,7 @@
 /* pr39500: autopar fails to parallel */
 /* origin: nemokingdom@gmail.com(LiFeng) */
 /* { dg-do compile } */
-/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops2-details" } */
+/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -ftree-parallelize-loops=4 -fdump-tree-parloops2-details" } */
 
 void abort (void);
 
index 0d611b96eae74756cc3a909738f893e38de6e6ae..a340240b86bd8fe66ae7b6ddf7e007dea74baf02 100644 (file)
@@ -61,5 +61,5 @@ int main (void)
 
 
 /* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops2" } } */
-/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 4 "parloops2" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops2" } } */
 
index efae736db1d020fa6080748c509d65169906f9cb..85b9437298bd447c428a67f5a12981621f0eff09 100644 (file)
@@ -85,5 +85,5 @@ int main (void)
 
 
 /* { dg-final { scan-tree-dump-times "Detected reduction" 2 "parloops2" } } */
-/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops2" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 2 "parloops2" } } */
 
index a2691294b07285ff3a12d7bd47be717e8f9f63d6..42171a2fbf385ea9ab90e013c51ff6cd8dc718e0 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do run { target vect_cmdline_needed } } */
-/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic" } */
-/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic -mno-sse" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic" } */
+/* { dg-additional-options "-mno-sse" { target { i?86-*-* x86_64-*-* } } } */
 
 #include <stdlib.h>
 
index 8e5f1410612b075914000dcdc643b2838ee3dcd9..242316893c030a7af3287d855695d2a79d288341 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do run { target vect_cmdline_needed } } */
-/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic" } */
-/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic -mno-sse" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic" } */
+/* { dg-additional-options "-mno-sse" { target { i?86-*-* x86_64-*-* } } } */
 
 #include <stdlib.h>
 
index ce97e0970b517db7fe43fb80838be6bf1048c884..24853e0e0db6d0a5717f4c545101569ccebce259 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do run { target vect_cmdline_needed } } */
-/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic" } */
-/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic -mno-sse" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -ftree-vectorize -fdump-tree-vect-details -fvect-cost-model=dynamic" } */
+/* { dg-additional-options "-mno-sse" { target { i?86-*-* x86_64-*-* } } } */
 
 #include <stdlib.h>
 
index 8fce4385d0b4ecd136f495cfd4296075903ad7b8..c4bee19b75aba447cca4d2c25092b8d8f2d1d297 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do run { target vect_cmdline_needed } } */
-/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details -fno-vect-cost-model" } */
+/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -ftree-vectorize -fdump-tree-vect-details -fno-vect-cost-model" } */
 /* { dg-additional-options "-mno-sse" { target { i?86-*-* x86_64-*-* } } } */
 
 #include <stdlib.h>
index 634f1dd51d39f00c9ed8accc930cb1a9c8504ccb..bdbdbff19ffbf32c365e269ef11f94bc7d9cece8 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-ivopts" } */
+/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -fdump-tree-ivopts" } */
 /* { dg-skip-if "PR68644" { hppa*-*-* powerpc*-*-* } } */
 
 void
index 171c85ab38db2fdf8656d1fc7973b94f5e903582..7d5859b3fce98aaf6811678cad0d5670ce59adca 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-ivopts" } */
+/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -fdump-tree-ivopts" } */
 /* { dg-require-effective-target stdint_types } */
 
 #include "stdint.h"
index d3a2339e55e550831f481aa9b8743b165d0e485f..b61b651fca85f74ec34179f5b0e9afc067410d30 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+/* { dg-options "-O2 -fno-inline -fno-tree-loop-distribute-patterns -fpredictive-commoning -fdump-tree-pcom-details" } */
 
 int arr[105] = {2, 3, 5, 7, 11};
 int result0[10] = {2, 3, 5, 7, 11};
index c48d438e9e0967c8bb430c5c102b5eae2a3fc15d..7f959a833f4a26bf268aac93253abb08b7187aa1 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+/* { dg-options "-O2 -fno-inline -fno-tree-loop-distribute-patterns -fpredictive-commoning -fdump-tree-pcom-details" } */
 
 int arr[105] = {2, 3, 5, 7, 11};
 int result0[10] = {2, 3, 5, 7, 11};
index 9c2736cd0ad20d5749e2c20070d93ac476b69990..ec08d6c0318245e1b5eec067f51a683103470920 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+/* { dg-options "-O2 -fno-inline -fno-tree-loop-distribute-patterns -fpredictive-commoning -fdump-tree-pcom-details" } */
 
 int arr1[105] = {2, 3, 5, 7, 11, 13, 0};
 int arr2[105] = {2, 3, 5, 7, 11, 13, 0};
index 302425a17ccde05447cf2d735cad411e029aaaea..f97d32f4b41dd2b5bbeb80ab577d9c805331d664 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+/* { dg-options "-O2 -fno-inline -fno-tree-loop-distribute-patterns -fpredictive-commoning -fdump-tree-pcom-details" } */
 
 int arr[105] = {2, 3, 5, 7, 11};
 int result0[10] = {2, 3, 5, 7, 11};
index c9f70271892e47ae4ee9f09f88dcde3d47231ef0..26de8719dc2b89278de92457739290dcbcecac80 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
-/* { dg-options "-O2 -fprefetch-loop-arrays -march=amdfam10 --param simultaneous-prefetches=100 -fdump-tree-aprefetch-details -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -fprefetch-loop-arrays -march=amdfam10 --param simultaneous-prefetches=100 -fdump-tree-aprefetch-details -fdump-tree-optimized" } */
 
 #define K 1000000
 int a[K];
index fe433ac3a7f08c0a620f5eb4999c5cbd779d5586..cbd6a80d3459a26aab4392174ac362d1b938123a 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
-/* { dg-options "-O2 -fprefetch-loop-arrays -march=amdfam10 --param simultaneous-prefetches=100 -fdump-tree-aprefetch-details -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -fprefetch-loop-arrays -march=amdfam10 --param simultaneous-prefetches=100 -fdump-tree-aprefetch-details -fdump-tree-optimized" } */
 
 #define K 1000000
 int a[K];
index 5be9282c9beac92a9ba341a206ddc9f12774cac5..da4847320b1fdb6b760ed8c48e10e76136404437 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
-/* { dg-options "-O2 -fprefetch-loop-arrays -march=amdfam10 --param simultaneous-prefetches=100 -fdump-tree-aprefetch-details -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fno-tree-loop-distribute-patterns -fprefetch-loop-arrays -march=amdfam10 --param simultaneous-prefetches=100 -fdump-tree-aprefetch-details -fdump-tree-optimized" } */
 
 #define K 1000000
 int a[K], b[K];
index c665fd7f20d241ac3441b7676f72b241c9eccc99..2336239652e5f0fd7b9e431a469886b597ca3fe7 100644 (file)
@@ -15,7 +15,7 @@ foo (int n)
     {
       unsigned char uc = (unsigned char)i;
       a[i] = i;
-      b[uc] = 0;
+      b[uc] = 1;
     }
 
   bar (a);
index 133ab0edca07bd3dbdc760637ae32d52bda2e5fb..cc50a5bde01315be13058ac3409db07f4ce6de5f 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target vect_int } */
+/* { dg-additional-options "-fno-tree-loop-distribute-patterns" } */
 
 #include <stdarg.h>
 #include "../../tree-vect.h"
index 242427dc48655c5604e1d00e0683823ed290ff87..b82b8916be125b194a02aa74cef74f821796de7f 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target vect_int } */
+/* { dg-additional-options "-fno-tree-loop-distribute-patterns" } */
 
 #include <stdarg.h>
 #include "../../tree-vect.h"
index 133ab0edca07bd3dbdc760637ae32d52bda2e5fb..cc50a5bde01315be13058ac3409db07f4ce6de5f 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target vect_int } */
+/* { dg-additional-options "-fno-tree-loop-distribute-patterns" } */
 
 #include <stdarg.h>
 #include "../../tree-vect.h"
index 33bf7f1a5a6106c0d900e8682fb1d8b097b3aea7..5e4affae7db61a0a07568603f1c80aefaf819adb 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target vect_int } */
+/* { dg-additional-options "-fno-tree-loop-distribute-patterns" } */
 
 #include <stdarg.h>
 #include "../../tree-vect.h"
index 8e012d49edf26d050980a0fe072d1258c17042b0..9569ea5c02f1b92fef091ec9b4267183b7a44784 100644 (file)
@@ -45,7 +45,7 @@ if ![check_vect_support_and_set_flags] {
 }
 
 # These flags are used for all targets.
-lappend DEFAULT_VECTCFLAGS "-ftree-vectorize" "-fno-vect-cost-model" "-fno-common"
+lappend DEFAULT_VECTCFLAGS "-ftree-vectorize" "-fno-tree-loop-distribute-patterns" "-fno-vect-cost-model" "-fno-common"
 
 # Initialize `dg'.
 dg-init
index b1fc2d3ecfa358804d7a618cca30dbf8ece8d5b5..263db5e05a6809a3519e40ec89d5de581a3be267 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile }
-/* { dg-options "-msse2 -O2 -ftree-vectorize -mtune=generic" } */
+/* { dg-options "-msse2 -O2 -fno-tree-loop-distribute-patterns -ftree-vectorize -mtune=generic" } */
 
 #define N 256
 int b[N];
index c44e669b0efacb687330b3c2757e2a58e5248dc4..180274c20a171589cfdc8291ab9781c989da444d 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-skip-if "" { *-*-* } { "-march=*" } { "-march=core2" } } */
-/* { dg-options "-O2 -ftree-vectorize -mfpmath=sse -march=core2 -fdump-tree-vect-stats" } */
+/* { dg-options "-O2 -ftree-vectorize -fno-tree-loop-distribute-patterns -mfpmath=sse -march=core2 -fdump-tree-vect-stats" } */
 /* { dg-add-options bind_pic_locally } */
 
 extern void abort (void);
index f6a43749407eda56d25c8692043b0caa1305c9ed..eea53bfa6b1132a93ea7a9f54a34a108c8c76158 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ftree-vectorize -mfpmath=sse -msse2 -mtune=atom -fdump-tree-vect-stats" } */
+/* { dg-options "-O2 -ftree-vectorize -fno-tree-loop-distribute-patterns -mfpmath=sse -msse2 -mtune=atom -fdump-tree-vect-stats" } */
 
 extern void abort (void);
 
index de283e8b85ff15e326b113a36693044415d3268c..b11cabaee23d78476f3702fdcb8a74e47e685784 100644 (file)
@@ -1,5 +1,5 @@
 ! { dg-require-effective-target vect_int }
-! { dg-additional-options "--param vect-max-peeling-for-alignment=0" }
+! { dg-additional-options "-fno-tree-loop-distribute-patterns --param vect-max-peeling-for-alignment=0" }
 
         Subroutine foo (N, M)
         Integer N
index 0ac5f1c390b365bdb04e49b8e94b10bcb15f0eea..e26cdf95e5158152c790dcaed420ef6ddae4849f 100644 (file)
@@ -1,6 +1,6 @@
 ! { dg-do compile }
 ! { dg-require-effective-target vect_double }
-! { dg-additional-options "-finline-matmul-limit=0" }
+! { dg-additional-options "-fno-tree-loop-distribute-patterns -finline-matmul-limit=0" }
 
 module lfk_prec
  integer, parameter :: dp=kind(1.d0)
index 3d8f13c4d14b21062c93f3e83c20798762b9ba4d..5f03b87f9c1aa5cb325f7e170841d782750e3d28 100644 (file)
@@ -115,6 +115,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "tree-vectorizer.h"
 #include "tree-eh.h"
+#include "gimple-fold.h"
 
 
 #define MAX_DATAREFS_NUM \
@@ -1028,6 +1029,7 @@ generate_memset_builtin (struct loop *loop, partition *partition)
   fn = build_fold_addr_expr (builtin_decl_implicit (BUILT_IN_MEMSET));
   fn_call = gimple_build_call (fn, 3, mem, val, nb_bytes);
   gsi_insert_after (&gsi, fn_call, GSI_CONTINUE_LINKING);
+  fold_stmt (&gsi);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
@@ -1071,6 +1073,7 @@ generate_memcpy_builtin (struct loop *loop, partition *partition)
   fn = build_fold_addr_expr (builtin_decl_implicit (kind));
   fn_call = gimple_build_call (fn, 3, dest, src, nb_bytes);
   gsi_insert_after (&gsi, fn_call, GSI_CONTINUE_LINKING);
+  fold_stmt (&gsi);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
@@ -2769,7 +2772,8 @@ finalize_partitions (struct loop *loop, vec<struct partition *> *partitions,
 
 static int
 distribute_loop (struct loop *loop, vec<gimple *> stmts,
-                control_dependences *cd, int *nb_calls, bool *destroy_p)
+                control_dependences *cd, int *nb_calls, bool *destroy_p,
+                bool only_patterns_p)
 {
   ddrs_table = new hash_table<ddr_hasher> (389);
   struct graph *rdg;
@@ -2843,7 +2847,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
 
   /* If we are only distributing patterns but did not detect any,
      simply bail out.  */
-  if (!flag_tree_loop_distribution
+  if (only_patterns_p
       && !any_builtin)
     {
       nbp = 0;
@@ -2855,7 +2859,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
      a loop into pieces, separated by builtin calls.  That is, we
      only want no or a single loop body remaining.  */
   struct partition *into;
-  if (!flag_tree_loop_distribution)
+  if (only_patterns_p)
     {
       for (i = 0; partitions.iterate (i, &into); ++i)
        if (!partition_builtin_p (into))
@@ -3085,7 +3089,6 @@ prepare_perfect_loop_nest (struct loop *loop)
         && loop_outer (outer)
         && outer->inner == loop && loop->next == NULL
         && single_exit (outer)
-        && optimize_loop_for_speed_p (outer)
         && !chrec_contains_symbols_defined_in_loop (niters, outer->num)
         && (niters = number_of_latch_executions (outer)) != NULL_TREE
         && niters != chrec_dont_know)
@@ -3139,9 +3142,11 @@ pass_loop_distribution::execute (function *fun)
      walking to innermost loops.  */
   FOR_EACH_LOOP (loop, LI_ONLY_INNERMOST)
     {
-      /* Don't distribute multiple exit edges loop, or cold loop.  */
+      /* Don't distribute multiple exit edges loop, or cold loop when
+         not doing pattern detection.  */
       if (!single_exit (loop)
-         || !optimize_loop_for_speed_p (loop))
+         || (!flag_tree_loop_distribute_patterns
+             && !optimize_loop_for_speed_p (loop)))
        continue;
 
       /* Don't distribute loop if niters is unknown.  */
@@ -3169,9 +3174,10 @@ pass_loop_distribution::execute (function *fun)
 
          bool destroy_p;
          int nb_generated_loops, nb_generated_calls;
-         nb_generated_loops = distribute_loop (loop, work_list, cd,
-                                               &nb_generated_calls,
-                                               &destroy_p);
+         nb_generated_loops
+           = distribute_loop (loop, work_list, cd, &nb_generated_calls,
+                              &destroy_p, (!optimize_loop_for_speed_p (loop)
+                                           || !flag_tree_loop_distribution));
          if (destroy_p)
            loops_to_be_destroyed.safe_push (loop);