diff mbox series

Fix some profile consistency testcases

Message ID ZKhJISgInYN208nc@kam.mff.cuni.cz
State New
Headers show
Series Fix some profile consistency testcases | expand

Commit Message

Jan Hubicka July 7, 2023, 5:19 p.m. UTC
Hi,
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.

Regtested x86_64-linux, will commit it shortly.
Honza
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.
diff mbox series

Patch

diff --git a/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C b/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C
index b45417106d0..1f7404600ed 100644
--- a/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C
+++ b/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C
@@ -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 () {}
diff --git a/gcc/testsuite/gcc.dg/pr43864-2.c b/gcc/testsuite/gcc.dg/pr43864-2.c
index 6393144ccf7..102295ad4e8 100644
--- a/gcc/testsuite/gcc.dg/pr43864-2.c
+++ b/gcc/testsuite/gcc.dg/pr43864-2.c
@@ -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)
diff --git a/gcc/testsuite/gcc.dg/pr43864-3.c b/gcc/testsuite/gcc.dg/pr43864-3.c
index 24b59a14b96..f70b8764cc8 100644
--- a/gcc/testsuite/gcc.dg/pr43864-3.c
+++ b/gcc/testsuite/gcc.dg/pr43864-3.c
@@ -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.  */
 
diff --git a/gcc/testsuite/gcc.dg/pr43864-4.c b/gcc/testsuite/gcc.dg/pr43864-4.c
index 8a25b0fd8ef..3de71fccfa2 100644
--- a/gcc/testsuite/gcc.dg/pr43864-4.c
+++ b/gcc/testsuite/gcc.dg/pr43864-4.c
@@ -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.  */
 
diff --git a/gcc/testsuite/gcc.dg/pr43864.c b/gcc/testsuite/gcc.dg/pr43864.c
index ed69a737d3f..7bd1ba69281 100644
--- a/gcc/testsuite/gcc.dg/pr43864.c
+++ b/gcc/testsuite/gcc.dg/pr43864.c
@@ -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 *);
diff --git a/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c b/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c
index b85e6c1f93d..15e1a97b1e6 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c
@@ -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
diff --git a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
index 702045239f3..0a45872e987 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c
@@ -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)
 {
diff --git a/gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c b/gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c
index c286816cdf8..e99ce532142 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c
@@ -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()
diff --git a/gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c b/gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c
index 57e781c7991..bfee3148d97 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c
@@ -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)
 {
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c
index 8495c4caf89..d2fe21c378a 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
index 4f758af71ca..3c4bc8d0b51 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c
index 5897d750d80..74e1a3f9905 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c
index b13601ede69..602e8e66656 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c
index 982bcb13435..087310fab57 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c
@@ -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
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/fnsplit-1.c b/gcc/testsuite/gcc.dg/tree-ssa/fnsplit-1.c
index 1b9696dcb11..470f5ee856d 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/fnsplit-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/fnsplit-1.c
@@ -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];
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-ch-profile-1.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-ch-profile-1.c
index e8bab62b0d9..16340868abf 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-ch-profile-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-ch-profile-1.c
@@ -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 *-*-* }} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-ch-profile-2.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-ch-profile-2.c
index 99d22ba6213..09270be01c7 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-ch-profile-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-ch-profile-2.c
@@ -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()
 {
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/update-cunroll.c b/gcc/testsuite/gcc.dg/tree-ssa/update-cunroll.c
index 3b47ede3918..5820423bd1c 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/update-cunroll.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/update-cunroll.c
@@ -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 *-*-*}} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c b/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c
index 9c87ba0f7bd..1435e9ba2e0 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c
@@ -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;
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/update-unroll-1.c b/gcc/testsuite/gcc.dg/tree-ssa/update-unroll-1.c
index 1028c8b06f5..138448bac43 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/update-unroll-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/update-unroll-1.c
@@ -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"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/update-unswitch-1.c b/gcc/testsuite/gcc.dg/tree-ssa/update-unswitch-1.c
index a48710d563b..65154d803e0 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/update-unswitch-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/update-unswitch-1.c
@@ -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)
 {
diff --git a/gcc/testsuite/gcc.dg/unroll-7.c b/gcc/testsuite/gcc.dg/unroll-7.c
index 695af5757cc..17c5e533c2c 100644
--- a/gcc/testsuite/gcc.dg/unroll-7.c
+++ b/gcc/testsuite/gcc.dg/unroll-7.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/unroll-8.c b/gcc/testsuite/gcc.dg/unroll-8.c
index c4f6ac91581..4388f47d4c7 100644
--- a/gcc/testsuite/gcc.dg/unroll-8.c
+++ b/gcc/testsuite/gcc.dg/unroll-8.c
@@ -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];};
diff --git a/gcc/testsuite/gfortran.dg/pr25623-2.f90 b/gcc/testsuite/gfortran.dg/pr25623-2.f90
index 57679e0d6ed..c7a4fe0c30e 100644
--- a/gcc/testsuite/gfortran.dg/pr25623-2.f90
+++ b/gcc/testsuite/gfortran.dg/pr25623-2.f90
@@ -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
diff --git a/gcc/testsuite/gfortran.dg/pr25623.f90 b/gcc/testsuite/gfortran.dg/pr25623.f90
index 30905e4841c..7302f37180a 100644
--- a/gcc/testsuite/gfortran.dg/pr25623.f90
+++ b/gcc/testsuite/gfortran.dg/pr25623.f90
@@ -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