]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix builtin vs non-builtin partition merge in loop distribution
authorRichard Biener <rguenther@suse.de>
Mon, 18 Jul 2022 11:09:57 +0000 (13:09 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 18 Jul 2022 12:42:51 +0000 (14:42 +0200)
When r7-6373-g40b6bff965d004 fixed a costing issue it failed to
make the logic symmetric which means that we now fuse
normal vs. builtin when the cost model says so but we don't fuse
builtin vs. normal.  The following fixes that, also allowing
the cost model to decide to fuse two builtin partitions as otherwise
an intermediate non-builtin can result in a partial merge as well.

* tree-loop-distribution.cc (loop_distribution::distribute_loop):
When computing cost-based merging do not disregard builtin
classified partitions in some cases.

* gcc.dg/tree-ssa/ldist-24.c: XFAIL.
* gcc.dg/tree-ssa/ldist-36.c: Adjust expected outcome.

gcc/testsuite/gcc.dg/tree-ssa/ldist-24.c
gcc/testsuite/gcc.dg/tree-ssa/ldist-36.c
gcc/tree-loop-distribution.cc

index 75f7b8f0c88c5db782c1e3f6c85978de1e4f7e7d..2403a24293b778c163f6176f8e0e27f9607323dd 100644 (file)
@@ -20,5 +20,6 @@ void foo ()
       }
 }
 
-/* { dg-final { scan-tree-dump "generated memcpy" "ldist" } } */
-/* { dg-final { scan-tree-dump "generated memset zero" "ldist" } } */
+/* The cost modeling does not consider WAR as beneficial to split.  */
+/* { dg-final { scan-tree-dump "generated memcpy" "ldist" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump "generated memset zero" "ldist" { xfail *-*-* } } } */
index 07393f0a665afd7000782fda1edf899bb09f488e..6d560060e09a89bff416ccf3348a4ba82e65b6be 100644 (file)
@@ -25,4 +25,5 @@ foo (struct st * restrict p)
     }
 }
 
-/* { dg-final { scan-tree-dump-times "Loop nest . distributed: split to 0 loops and 3 library" 1 "ldist" } } */
+/* The cost modeling doesn't consider splitting a WAR re-use profitable.  */
+/* { dg-final { scan-tree-dump-times "Loop nest . distributed: split to 1 loops and 1 library" 1 "ldist" } } */
index 0714bc41a43e7e6ad68f14216e18094567d4a378..0ee441c077d07c1192f74585f46206d1b5049971 100644 (file)
@@ -3090,10 +3090,7 @@ loop_distribution::distribute_loop (class loop *loop,
   for (i = 0; partitions.iterate (i, &into); ++i)
     {
       bool changed = false;
-      if (partition_builtin_p (into) || into->kind == PKIND_PARTIAL_MEMSET)
-       continue;
-      for (int j = i + 1;
-          partitions.iterate (j, &partition); ++j)
+      for (int j = i + 1; partitions.iterate (j, &partition); ++j)
        {
          if (share_memory_accesses (rdg, into, partition))
            {