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
+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.
-/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile -fdump-ipa-afdo" } */
struct A {
A () {}
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"
void test2 (B *tc)
{
int i;
- for (i = 0; i < 1000; i++)
+ for (i = 0; i < 1000000; i++)
g += tc->foo();
}
}
-/* { 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" } } */
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"
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++;
}
void test2 (B *tc)
{
int i;
- for (i = 0; i < 1000; i++)
+ for (i = 0; i < 1000000; i++)
g += tc->foo();
}
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" } } */
return 0;
}
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "dom2"} } */
+/* { dg-final-use-not-autofdo { scan-tree-dump-not "Invalid sum" "dom2"} } */
exit (0);
}
-/* { dg-final-use { scan-tree-dump-not "Invalid sum" "dom2"} } */
+/* { dg-final-use-not-autofdo { scan-tree-dump-not "Invalid sum" "dom2"} } */
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;
}
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)
{
int (*p) (void);
int i;
- for (i = 0; i < 10; i ++)
+ for (i = 0; i < 10000000; i ++)
{
setp (&p, i);
p ();
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"} } */
main ()
{
int i;
- for (i = 0; i < 100; i++)
+ for (i = 0; i < 1000000; i++)
{
if (a)
cold_function ();
{
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;
}
}
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"} } */
}
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"} } */
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"} } */
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"} } */
{
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"} } */
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"} } */
/* 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"} } */
}
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"} } */
}
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"} } */
}
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"} } */
}
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"} } */
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"} } */
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"} } */
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" } } */