Commit f63ba78c by Andi Kleen Committed by Andi Kleen

Some fixes for profile test cases for autofdo

This fixes some basic issues with the profile test cases with autofdo.

- Disable checking for value transformations that autofdo does not
  support.
- Disable checking for fixed hit counts which autofdo does not support
- Enable dumping of afdo log file and check right log file.
- Increase run time of test cases to 1M iterations because autofdo needs
  a few samples to make sense of a program. The test case don't run
  noticeable slower with that.

There are still failures unfortunately, especially the indirect call
transformations do not trigger because autofdo thinks they are not hot.
This can be addressed later.

gcc/testsuite/:

2016-07-13  Andi Kleen  <ak@linux.intel.com>

	* g++.dg/tree-prof/indir-call-prof.C: Basic fixes for autofdo.
	* g++.dg/tree-prof/morefunc.C: Dito.
	* g++.dg/tree-prof/pr35545.C: Dito.
	* g++.dg/tree-prof/reorder.C: Dito.
	* gcc.dg/tree-prof/20050826-2.c: Dito.
	* gcc.dg/tree-prof/cmpsf-1.c: Dito.
	* gcc.dg/tree-prof/cold_partition_label.c: Dito.
	* gcc.dg/tree-prof/ic-misattribution-1.c: Dito.
	* gcc.dg/tree-prof/indir-call-prof.c: Dito.
	* gcc.dg/tree-prof/inliner-1.c: Dito.
	* gcc.dg/tree-prof/merge_block.c: Dito.
	* gcc.dg/tree-prof/stringop-1.c: Dito.
	* gcc.dg/tree-prof/stringop-2.c: Dito.
	* gcc.dg/tree-prof/switch-case-1.c: Dito.
	* gcc.dg/tree-prof/switch-case-2.c: Dito.
	* gcc.dg/tree-prof/time-profiler-1.c: Dito.
	* gcc.dg/tree-prof/time-profiler-2.c: Dito.
	* gcc.dg/tree-prof/update-loopch.c: Dito.
	* gcc.dg/tree-prof/val-prof-1.c: Dito.
	* gcc.dg/tree-prof/val-prof-2.c: Dito.
	* gcc.dg/tree-prof/val-prof-3.c: Dito.
	* gcc.dg/tree-prof/val-prof-4.c: Dito.
	* gcc.dg/tree-prof/val-prof-5.c: Dito.
	* gcc.dg/tree-prof/val-prof-6.c: Dito.
	* gcc.dg/tree-prof/val-prof-7.c: Dito.

From-SVN: r238325
parent f4d5a23d
2016-07-13 Andi Kleen <ak@linux.intel.com>
* g++.dg/tree-prof/indir-call-prof.C: Basic fixes for autofdo.
* g++.dg/tree-prof/morefunc.C: Dito.
* g++.dg/tree-prof/pr35545.C: Dito.
* g++.dg/tree-prof/reorder.C: Dito.
* gcc.dg/tree-prof/20050826-2.c: Dito.
* gcc.dg/tree-prof/cmpsf-1.c: Dito.
* gcc.dg/tree-prof/cold_partition_label.c: Dito.
* gcc.dg/tree-prof/ic-misattribution-1.c: Dito.
* gcc.dg/tree-prof/indir-call-prof.c: Dito.
* gcc.dg/tree-prof/inliner-1.c: Dito.
* gcc.dg/tree-prof/merge_block.c: Dito.
* gcc.dg/tree-prof/stringop-1.c: Dito.
* gcc.dg/tree-prof/stringop-2.c: Dito.
* gcc.dg/tree-prof/switch-case-1.c: Dito.
* gcc.dg/tree-prof/switch-case-2.c: Dito.
* gcc.dg/tree-prof/time-profiler-1.c: Dito.
* gcc.dg/tree-prof/time-profiler-2.c: Dito.
* gcc.dg/tree-prof/update-loopch.c: Dito.
* gcc.dg/tree-prof/val-prof-1.c: Dito.
* gcc.dg/tree-prof/val-prof-2.c: Dito.
* gcc.dg/tree-prof/val-prof-3.c: Dito.
* gcc.dg/tree-prof/val-prof-4.c: Dito.
* gcc.dg/tree-prof/val-prof-5.c: Dito.
* gcc.dg/tree-prof/val-prof-6.c: Dito.
* gcc.dg/tree-prof/val-prof-7.c: Dito.
2016-07-13 Andi Kleen <ak@linux.intel.com>
* lib/profopt.exp (profopt-execute): Remove .imports files.
2016-07-13 Andi Kleen <ak@linux.intel.com>
......
/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile -fdump-ipa-afdo" } */
struct A {
A () {}
......@@ -24,14 +24,20 @@ main (void)
A* p;
p = (A *)wrap ((void *)&a);
p->AA ();
int i;
p = (B *)wrap ((void *)&b);
p->AA ();
for (i = 0; i < 1000000; i++)
{
p = (A *)wrap ((void *)&a);
p->AA ();
p = (B *)wrap ((void *)&b);
p->AA ();
}
return 0;
}
/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call.* AA transformation on insn" "profile" } } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Indirect call -> direct call.* AA transformation on insn" "profile" } } */
/* { dg-final-use-autofdo { scan-ipa-dump "Indirect call -> direct call.* AA transformation on insn" "afdo" } } */
/* { dg-final-use-not-autofdo { scan-tree-dump-not "Invalid sum" "optimized" } } */
/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -Wno-attributes -Wno-coverage-mismatch" } */
/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -fdump-ipa-afdo -Wno-attributes -Wno-coverage-mismatch" } */
#include "reorder_class1.h"
#include "reorder_class2.h"
......@@ -28,7 +28,7 @@ static __attribute__((always_inline))
void test2 (B *tc)
{
int i;
for (i = 0; i < 1000; i++)
for (i = 0; i < 1000000; i++)
g += tc->foo();
}
......@@ -51,4 +51,5 @@ int main()
}
/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */
/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */
/* { dg-final-use-autofdo { scan-ipa-dump-times "Indirect call -> direct call" 2 "afdo" } } */
......@@ -27,7 +27,7 @@ int main()
A* ap = 0;
for (i = 0; i < 10000; i++)
for (i = 0; i < 1000000; i++)
{
if (i%7==0)
......
/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -Wno-coverage-mismatch -Wno-attributes" } */
/* { dg-options "-O2 -fno-devirtualize --param=profile-func-internal-id=0 -fdump-ipa-profile -fdump-ipa-afdo -Wno-coverage-mismatch -Wno-attributes" } */
#ifdef _PROFILE_USE
#include "reorder_class1.h"
......@@ -13,7 +13,7 @@ static __attribute__((always_inline))
void test1 (A *tc)
{
int i;
for (i = 0; i < 1000; i++)
for (i = 0; i < 1000000; i++)
g += tc->foo();
if (g<100) g++;
}
......@@ -22,7 +22,7 @@ static __attribute__((always_inline))
void test2 (B *tc)
{
int i;
for (i = 0; i < 1000; i++)
for (i = 0; i < 1000000; i++)
g += tc->foo();
}
......@@ -44,4 +44,5 @@ int main()
test_b(bp);
}
/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */
/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */
/* { dg-final-use-autofdo { scan-ipa-dump-times "Indirect call -> direct call" 2 "afdo" } } */
......@@ -72,4 +72,4 @@ main (void)
return 0;
}
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "dom2"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump-not "Invalid sum" "dom2"} } */
......@@ -181,4 +181,4 @@ main (void)
exit (0);
}
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "dom2"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump-not "Invalid sum" "dom2"} } */
......@@ -29,9 +29,11 @@ foo (int path)
int
main (int argc, char *argv[])
{
int i;
buf_hot = "hello";
buf_cold = "world";
foo (argc);
for (i = 0; i < 1000000; i++)
foo (argc);
return 0;
}
......
......@@ -15,4 +15,4 @@ caller(void (*func) (void))
func ();
}
/* { dg-final-use { scan-ipa-dump "hist->count 1 hist->all 1" "profile" } } */
/* { dg-final-use-not-autofdo { scan-ipa-dump "hist->count 1 hist->all 1" "profile" } } */
/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile -fdump-ipa-afdo" } */
static int a1 (void)
{
......@@ -28,7 +28,7 @@ main (void)
int (*p) (void);
int i;
for (i = 0; i < 10; i ++)
for (i = 0; i < 10000000; i ++)
{
setp (&p, i);
p ();
......@@ -37,5 +37,6 @@ main (void)
return 0;
}
/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call.* a1 transformation on insn" "profile"} } */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Indirect call -> direct call.* a1 transformation on insn" "profile"} } */
/* { dg-final-use-autofdo { scan-ipa-dump "Indirect call -> direct call.* a1 transformation on insn" "afdo"} } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
......@@ -25,7 +25,7 @@ int
main ()
{
int i;
for (i = 0; i < 100; i++)
for (i = 0; i < 1000000; i++)
{
if (a)
cold_function ();
......
......@@ -14,7 +14,7 @@ main ()
{
int i;
/* The loop will be optimized away after ipa-inline. */
for (i = 0; i < 1000; i++)
for (i = 0; i < 1000000; i++)
t ();
return 0;
}
......
......@@ -14,8 +14,9 @@ main()
}
return 0;
}
/* { dg-final-use { scan-ipa-dump "Single value 4 stringop" "profile"} } */
/* autofdo doesn't support value profiling for now: */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 4 stringop" "profile"} } */
/* Really this ought to simplify into assignment, but we are not there yet. */
/* a[0] = b[0] is what we fold the resulting memcpy into. */
/* { dg-final-use { scan-tree-dump " = MEM.*&b" "optimized"} } */
/* { dg-final-use { scan-tree-dump "MEM.*&a\\\] = " "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump " = MEM.*&b" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "MEM.*&a\\\] = " "optimized"} } */
......@@ -19,6 +19,7 @@ main()
}
return 0;
}
/* { dg-final-use { scan-ipa-dump "Single value 4 stringop" "profile"} } */
/* autofdo doesn't support value profiling for now: */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 4 stringop" "profile"} } */
/* The versioned memset of size 4 should be optimized to an assignment. */
/* { dg-final-use { scan-tree-dump "MEM\\\[\\(void .\\)&a\\\] = 168430090" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "MEM\\\[\\(void .\\)&a\\\] = 168430090" "optimized"} } */
......@@ -35,5 +35,6 @@ int main ()
foo ((i * i) % 5);
return 0;
}
/* { dg-final-use { scan-rtl-dump-times ";; basic block\[^\\n\]*count 4000" 2 "expand"} } */
/* { dg-final-use { scan-rtl-dump-times ";; basic block\[^\\n\]*count 2000" 1 "expand"} } */
/* autofdo cannot do that precise execution numbers */
/* { dg-final-use-not-autofdo { scan-rtl-dump-times ";; basic block\[^\\n\]*count 4000" 2 "expand"} } */
/* { dg-final-use-not-autofdo { scan-rtl-dump-times ";; basic block\[^\\n\]*count 2000" 1 "expand"} } */
......@@ -35,5 +35,6 @@ int main ()
foo ((i * i) % 5);
return 0;
}
/* { dg-final-use { scan-rtl-dump-times ";; basic block\[^\\n\]*count 4000" 2 "expand"} } */
/* { dg-final-use { scan-rtl-dump-times ";; basic block\[^\\n\]*count 2000" 1 "expand"} } */
/* autofdo cannot do that precise execution numbers: */
/* { dg-final-use-not-autofdo { scan-rtl-dump-times ";; basic block\[^\\n\]*count 4000" 2 "expand"} } */
/* { dg-final-use-not-autofdo { scan-rtl-dump-times ";; basic block\[^\\n\]*count 2000" 1 "expand"} } */
......@@ -16,6 +16,6 @@ int main ()
{
return foo ();
}
/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 0" 1 "profile"} } */
/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 1" 1 "profile"} } */
/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 2" 1 "profile"} } */
/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 0" 1 "profile"} } */
/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 1" 1 "profile"} } */
/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 2" 1 "profile"} } */
......@@ -43,7 +43,7 @@ int main ()
return r;
}
/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 0" 2 "profile"} } */
/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 1" 1 "profile"} } */
/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 2" 1 "profile"} } */
/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 3" 1 "profile"} } */
/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 0" 2 "profile"} } */
/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 1" 1 "profile"} } */
/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 2" 1 "profile"} } */
/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 3" 1 "profile"} } */
......@@ -14,8 +14,9 @@ main ()
/* Loop header copying will peel away the initial conditional, so the loop body
is once reached directly from entry point of function, rest via loopback
edge. */
/* { dg-final-use { scan-ipa-dump "loop depth 1, count 33334" "profile"} } */
/* { dg-final-use { scan-tree-dump "loop depth 1, count 33333" "optimized"} } */
/* { dg-final-use { scan-tree-dump-not "loop depth 1, count 33332" "optimized"} } */
/* { dg-final-use { scan-tree-dump "Removing basic block" "optimized"} } */
/* autofdo cannot do that precise counts */
/* { dg-final-use-not-autofdo { scan-ipa-dump "loop depth 1, count 33334" "profile"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "loop depth 1, count 33333" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump-not "loop depth 1, count 33332" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "Removing basic block" "optimized"} } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
......@@ -16,6 +16,7 @@ main ()
}
return 0;
}
/* { dg-final-use { scan-ipa-dump "Div.mod by constant n_\[0-9\]*=257 transformation on insn" "profile"} } */
/* { dg-final-use { scan-tree-dump "if \\(n_\[0-9\]* != 257\\)" "optimized"} } */
/* autofdo does not do value profiling so far */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Div.mod by constant n_\[0-9\]*=257 transformation on insn" "profile"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "if \\(n_\[0-9\]* != 257\\)" "optimized"} } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
......@@ -24,8 +24,9 @@ main ()
}
return 0;
}
/* { dg-final-use { scan-ipa-dump "Mod power of 2 transformation on insn" "profile" } } */
/* autofdo does not do value profiling so far */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Mod power of 2 transformation on insn" "profile" } } */
/* This is part of code checking that n is power of 2, so we are sure that the transformation
didn't get optimized out. */
/* { dg-final-use { scan-tree-dump "n_\[0-9\]* \\+ (4294967295|0x0*ffffffff)" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "n_\[0-9\]* \\+ (4294967295|0x0*ffffffff)" "optimized"} } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
......@@ -24,8 +24,9 @@ main ()
}
return 0;
}
/* { dg-final-use { scan-ipa-dump "Mod subtract transformation on insn" "profile" } } */
/* autofdo does not do value profiling so far */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Mod subtract transformation on insn" "profile" } } */
/* This is part of code checking that n is greater than the divisor so we are sure that it
didn't get optimized out. */
/* { dg-final-use { scan-tree-dump "if \\(_\[0-9\]* \\< n_\[0-9\]*" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "if \\(_\[0-9\]* \\< n_\[0-9\]*" "optimized"} } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
......@@ -24,8 +24,9 @@ main ()
}
return 0;
}
/* { dg-final-use { scan-ipa-dump "Mod subtract transformation on insn" "profile" } } */
/* autofdo does not do value profiling so far */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Mod subtract transformation on insn" "profile" } } */
/* This is part of code checking that n is greater than the divisor so we are sure that it
didn't get optimized out. */
/* { dg-final-use { scan-tree-dump "if \\(n_\[0-9\]* \\>" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "if \\(n_\[0-9\]* \\>" "optimized"} } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
......@@ -12,5 +12,6 @@ main()
a[i]/=b;
return 0;
}
/* { dg-final-use { scan-ipa-dump "Div.mod by constant b.*=997 transformation on insn" "profile" } } */
/* autofdo does not do value profiling so far */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Div.mod by constant b.*=997 transformation on insn" "profile" } } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
......@@ -15,5 +15,6 @@ main()
t(i);
return 0;
}
/* { dg-final-use { scan-tree-dump "Average value sum:499500" "optimized"} } */
/* { dg-final-use { scan-tree-dump "IOR value" "optimized"} } */
/* autofdo does not do value profiling so far */
/* { dg-final-use-not-autofdo { scan-tree-dump "Average value sum:499500" "optimized"} } */
/* { dg-final-use-not-autofdo { scan-tree-dump "IOR value" "optimized"} } */
......@@ -22,4 +22,4 @@ int main() {
return 0;
}
/* { dg-final-use { scan-ipa-dump "Single value 8 stringop transformation on bzero" "profile" } } */
/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 8 stringop transformation on bzero" "profile" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment