]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix some profile consistency testcases
authorJan Hubicka <jh@suse.cz>
Fri, 7 Jul 2023 17:16:59 +0000 (19:16 +0200)
committerJan Hubicka <jh@suse.cz>
Fri, 7 Jul 2023 17:16:59 +0000 (19:16 +0200)
Information about profile mismatches is printed only with -details-blocks for some time.
I think it should be printed even with default to make it easier to spot when someone introduces
new transform that breaks the profile, but I will send separate RFC for that.

This patch enables details in all testcases that greps for Invalid sum.  There are 4 testcases
which fails:
  gcc.dg/tree-ssa/loop-ch-profile-1.c
     here the problem is that loop header dulication introduces loop invariant conditoinal that is later
     updated by tree-ssa-dom but dom does not take care of updating profile.
     Since loop-ch knows when it duplicates loop invariant, we may be able to get this right.

     The test is still useful since it tests that right after ch profile is consistent.
  gcc.dg/tree-prof/update-cunroll-2.c
     This is about profile updating code in duplicate_loop_body_to_header_edge being wrong when optimized
     out exit is not last in the loop.  In that case the probability of later exits needs to be accounted in.
     I will think about making this better - in general this does not seem to have easy solution, but for
     special case of chained tests we can definitely account for the later exits.
  gcc.dg/tree-ssa/update-unroll-1.c
     This fails after aprefetch invoked unrolling.  I did not look into details yet.
  gcc.dg/tree-prof/update-unroll-2.c
     This one seems similar as previous
I decided to xfail these tests and deal with them incrementally and filled in PR110590.

gcc/testsuite/ChangeLog:

* g++.dg/tree-prof/indir-call-prof.C: Add block-details to dump flags.
* gcc.dg/pr43864-2.c: Likewise.
* gcc.dg/pr43864-3.c: Likewise.
* gcc.dg/pr43864-4.c: Likewise.
* gcc.dg/pr43864.c: Likewise.
* gcc.dg/tree-prof/cold_partition_label.c: Likewise.
* gcc.dg/tree-prof/indir-call-prof.c: Likewise.
* gcc.dg/tree-prof/update-cunroll-2.c: Likewise.
* gcc.dg/tree-prof/update-tailcall.c: Likewise.
* gcc.dg/tree-prof/val-prof-1.c: Likewise.
* gcc.dg/tree-prof/val-prof-2.c: Likewise.
* gcc.dg/tree-prof/val-prof-3.c: Likewise.
* gcc.dg/tree-prof/val-prof-4.c: Likewise.
* gcc.dg/tree-prof/val-prof-5.c: Likewise.
* gcc.dg/tree-ssa/fnsplit-1.c: Likewise.
* gcc.dg/tree-ssa/loop-ch-profile-2.c: Likewise.
* gcc.dg/tree-ssa/update-threading.c: Likewise.
* gcc.dg/tree-ssa/update-unswitch-1.c: Likewise.
* gcc.dg/unroll-7.c: Likewise.
* gcc.dg/unroll-8.c: Likewise.
* gfortran.dg/pr25623-2.f90: Likewise.
* gfortran.dg/pr25623.f90: Likewise.
* gcc.dg/tree-ssa/loop-ch-profile-1.c: Likewise; xfail.
* gcc.dg/tree-ssa/update-cunroll.c: Likewise; xfail.
* gcc.dg/tree-ssa/update-unroll-1.c: Likewise; xfail.

25 files changed:
gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C
gcc/testsuite/gcc.dg/pr43864-2.c
gcc/testsuite/gcc.dg/pr43864-3.c
gcc/testsuite/gcc.dg/pr43864-4.c
gcc/testsuite/gcc.dg/pr43864.c
gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c
gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c
gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c
gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c
gcc/testsuite/gcc.dg/tree-ssa/fnsplit-1.c
gcc/testsuite/gcc.dg/tree-ssa/loop-ch-profile-1.c
gcc/testsuite/gcc.dg/tree-ssa/loop-ch-profile-2.c
gcc/testsuite/gcc.dg/tree-ssa/update-cunroll.c
gcc/testsuite/gcc.dg/tree-ssa/update-threading.c
gcc/testsuite/gcc.dg/tree-ssa/update-unroll-1.c
gcc/testsuite/gcc.dg/tree-ssa/update-unswitch-1.c
gcc/testsuite/gcc.dg/unroll-7.c
gcc/testsuite/gcc.dg/unroll-8.c
gcc/testsuite/gfortran.dg/pr25623-2.f90
gcc/testsuite/gfortran.dg/pr25623.f90

index b45417106d0f751cab5cff62cd0be6568cd303a2..1f7404600ed98e02dcde3a23eb8174c5e0bb9013 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized -fdump-ipa-afdo-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized-blocks-details -fdump-ipa-profile-optimized -fdump-ipa-afdo-optimized" } */
 
 struct A {
   A () {}
index 6393144ccf73d7a9bd76a3f7235d3bb123c8d0bb..102295ad4e86dcb67633b63bc5cadd7df573c484 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */
+/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre-details-blocks" } */
 
 int
 f (int c, int b, int d)
index 24b59a14b96420052003e8f7fe87484499ee9102..f70b8764cc84c86507c229a684564a4aa2ad2f28 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */
+/* { dg-options "-O2 -fdump-tree-pre-blocks-details" } */
 
 /* Commutative case.  */
 
index 8a25b0fd8efbea8ecf28389950616bade6b61702..3de71fccfa2145203719f4997c93a56259499128 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */
+/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre-details-blocks" } */
 
 /* Different stmt order.  */
 
index ed69a737d3f284b3bb3546396dd29c9119511fc3..7bd1ba692818a7adfc72c54567e9d9029eaa412e 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */
+/* { dg-options "-O2 -fdump-tree-pre-details-blocks" } */
 
 extern void foo (char*, int);
 extern void mysprintf (char *, char *);
index b85e6c1f93deacd8111f0ff9447e86c42af3e9bf..15e1a97b1e6a5a645a6bbf8b13f376ec034cf40a 100644 (file)
@@ -1,7 +1,7 @@
 /* Test case to check if function foo gets split and the cold function
    gets a label.  */
 /* { dg-require-effective-target freorder } */
-/* { dg-options "-O2 -freorder-blocks-and-partition -save-temps -fdump-tree-optimized" } */
+/* { dg-options "-O2 -freorder-blocks-and-partition -save-temps -fdump-tree-optimized-details-blocks" } */
 
 #ifdef FOR_AUTOFDO_TESTING
 #define MAXITER 1000000
index 702045239f3f383ccb652ba35d7a495e2dd6e334..0a45872e987e170be15b5300f6f893cafe232e0a 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized -fdump-ipa-afdo-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized-details-blocks -fdump-ipa-profile-optimized -fdump-ipa-afdo-optimized" } */
 
 static int a1 (void)
 {
index c286816cdf8f1c7c9b76559c6eced34581788c97..8ef3ab2b5e4969bcd6ef8a94931e9e4e2e8fcb7a 100644 (file)
@@ -1,5 +1,5 @@
 
-/* { dg-options "-O2 -fdump-tree-optimized-blocks" } */
+/* { dg-options "-O2 -fdump-tree-optimized-details-blocks" } */
 int a[8];
 __attribute__ ((noinline))
 int t()
@@ -18,4 +18,4 @@ main ()
     t ();
   return 0;
 }
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
+/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized" {xfail *-*-*} } } */
index 57e781c7991bfaf6f07842e8996c0faf65154c4d..bfee3148d97c1db16aa9d33d3871a0f484603364 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-tailc -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-tailc-details-blocks -fdump-tree-optimized-details-blocks" } */
 __attribute__ ((noinline))
 int factorial(int x)
 {
index 8495c4caf89b349fd214c26dd3059f76502130f3..d2fe21c378a6665f827ab18d82c37a1d47254c9b 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized-details-blocks -fdump-ipa-profile-optimized" } */
 int a[1000];
 int b = 256;
 int c = 257;
index 4f758af71ca9a3adf1d4e7747718d5f15c4e0086..3c4bc8d0b51b59cfe09d38522cf4349f8c6d28f2 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized-details-blocks -fdump-ipa-profile-optimized" } */
 unsigned int a[1000];
 unsigned int b = 256;
 unsigned int c = 1024;
index 5897d750d80ee5aa797ca82771c717f47c53ca0c..74e1a3f990596f138a9706ec5f3e79b5e85e45a9 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized-details-blocks -fdump-ipa-profile-optimized" } */
 unsigned int a[1000];
 unsigned int b = 257;
 unsigned int c = 1023;
index b13601ede69f8dedbebb273b52cd7a2fa4b5b675..602e8e66656ea88a25e9f05ea7bd6caf21e38d6f 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized-details-blocks -fdump-ipa-profile-optimized" } */
 unsigned int a[1000];
 unsigned int b = 999;
 unsigned int c = 1002;
index 982bcb1343523dfe59598503d0539c9d37e57550..087310fab57eafda661aa5ac20ba5e4a23be531e 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized-details-blocks -fdump-ipa-profile-optimized" } */
 int a[1000];
 int b=997;
 int
index 1b9696dcb117be38913423b82299a0ec71e97ee2..470f5ee856d8b42d8799f70b2e93a3a68f95751d 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-fnsplit" } */
+/* { dg-options "-O2 -fdump-tree-fnsplit-blocks-details" } */
 #include <stdio.h>
 int a[1000];
 
index e8bab62b0d9b8f9ef44b15ccaefac58a4665266e..16340868abfb805e0e9b3ceb0d63b45b8e6d4dfc 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-ch2-blocks-details -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-ch2-blocks-details -fdump-tree-optimized-blocks-details" } */
 void foo ();
 void test(int v, int q)
 {
@@ -7,4 +7,6 @@ void test(int v, int q)
                foo ();
 }
 /* { dg-final { scan-tree-dump-not "Invalid sum" "ch2"} } */
-/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized"} } */
+/* dom2 optimizes out the redundant test for loop invariant v/q
+   which leads to inconsistent profile.  */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized"  { xfail *-*-* }} } */
index 99d22ba6213bb96ece82f946469791ddcfc3173f..09270be01c70b53dce55665615497fd74fdf368b 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-ch2-blocks-details -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-ch2-blocks-details -fdump-tree-optimized-blocks-details" } */
 void foo ();
 void test()
 {
index 3b47ede3918dd0aede5d79b568fc49d7403ee685..5820423bd1cfb59012b3b681c3cb4af69531626b 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized-details-blocks" } */
 int a[8];
 int t()
 {
@@ -9,4 +9,6 @@ int t()
                        break;
        return i;
 }
-/* { dg-final { scan-tree-dump-times "Invalid sum" 0 "optimized"} } */
+/* Currently duplicate_loop_body_to_header_edge gets wrong computation of prob_pass_wont_exit
+   which assumes that the exit condition is last in the loop.  */
+/* { dg-final { scan-tree-dump-times "Invalid sum" 0 "optimized" { xfail *-*-*}} } */
index 9c87ba0f7bd9183a445dc0f3d4cfaf24e787f593..1435e9ba2e0229b9454a58c61d9839135a8871a6 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized-blocks-details" } */
 
 typedef struct { unsigned short a; } A;
 
index 1028c8b06f5e93caae28e2b98f7d4bb381f087d8..138448bac4377d262c615297483d427186d72ac9 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
-/* { dg-options "-O1 -fprefetch-loop-arrays -march=amdfam10 -fdump-tree-aprefetch-blocks" } */
+/* { dg-options "-O1 -fprefetch-loop-arrays -march=amdfam10 -fdump-tree-aprefetch-blocks-details" } */
 
 int a[10000];
 
@@ -16,5 +16,5 @@ int foo(unsigned n)
 /* We used to make the probability that the body of the loop (unrolled
    to enable prefetching) is entered 0, which is not correct.  */
 
-/* { dg-final { scan-tree-dump-not "Invalid sum" "aprefetch"} } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "aprefetch" { xfail *-*-* }} } */
 /* { dg-final { scan-tree-dump-not "SUCC: 7 .100.0%" "aprefetch"} } */
index a48710d563b1a6b3844fb81d3cf5051003552615..65154d803e02093b63cafae028a022795cfc9584 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O1 -funswitch-loops -fdump-tree-unswitch-blocks" } */
+/* { dg-options "-O1 -funswitch-loops -fdump-tree-unswitch-blocks-details" } */
 
 int bla(int p)
 {
index 695af5757cc8196f565dfff23e0fa411e7cfc68b..17c5e533c2cb6308384d4f62dae650c6c540d0b8 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-vectorize -fdump-rtl-loop2_unroll-details -funroll-loops" } */
+/* { dg-options "-O2 -fno-tree-vectorize -fdump-rtl-loop2_unroll-blocks-details -funroll-loops" } */
 /* { dg-require-effective-target int32plus } */
 
 extern int *a;
index c4f6ac9158158e7eeedec7b3fde11edc9b96edb2..4388f47d4c74911a0be490b6f64418bf0311ffc1 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-rtl-loop2_unroll -funroll-loops" } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll-details-blocks -funroll-loops" } */
 /* { dg-additional-options "-fno-tree-vectorize" { target amdgcn-*-* } } */
 
 struct a {int a[7];};
index 57679e0d6ed63dc4dd48973e60e3391bcc27f49a..c7a4fe0c30e915e1b40d4c81c6f9da243d608fce 100644 (file)
@@ -1,5 +1,5 @@
 ! { dg-do compile }
-! { dg-options "-fdump-tree-optimized-blocks -O3" }
+! { dg-options "-fdump-tree-optimized-blocks-details -O3" }
 
 SUBROUTINE S42(a,b,c,N)
  IMPLICIT NONE
index 30905e4841c5a3376bfb2af83b613bee042be597..7302f37180a8f15df76dc8fa8d73540d3894bca3 100644 (file)
@@ -1,5 +1,5 @@
 ! { dg-do compile }
-! { dg-options "-fdump-tree-optimized-blocks -O2" }
+! { dg-options "-fdump-tree-optimized-blocks-details -O2" }
 
 SUBROUTINE S42(a,b,c,N)
  IMPLICIT NONE