]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add testcase for AFDO early inlining and indirect call promotion
authorJan Hubicka <hubicka@ucw.cz>
Tue, 17 Jun 2025 13:43:13 +0000 (15:43 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Tue, 17 Jun 2025 15:25:29 +0000 (17:25 +0200)
gcc/testsuite/ChangeLog:

* gcc.dg/tree-prof/afdo-vpt-earlyinline.c: New test.

gcc/testsuite/gcc.dg/tree-prof/afdo-vpt-earlyinline.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/tree-prof/afdo-vpt-earlyinline.c b/gcc/testsuite/gcc.dg/tree-prof/afdo-vpt-earlyinline.c
new file mode 100644 (file)
index 0000000..3b51ea9
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-options "-O2 -fdump-ipa-afdo-details -fdump-tree-einline-details" } */
+/* { dg-require-profiling "-fauto-profile" } */ 
+
+volatile int array[1000];
+int reta (int i)
+{
+       return array[i];
+}
+struct wrapptr 
+{
+       int (*ret)(int);
+};
+int test (struct wrapptr *p)
+{
+       int s = 0;
+       for (int pos = 0; pos < 1000; pos++)
+         s+p->ret(pos);
+       if (s)
+               __builtin_printf ("sum error\n");
+}
+int main()
+{
+       struct wrapptr p={reta};
+       for (int i = 0; i < 10000; i++)
+               test(&p);
+       return 0;
+}
+/* { dg-final-use-autofdo { scan-tree-dump "Inlining test" "einline"} } */
+/* { dg-final-use-autofdo { scan-ipa-dump "Checking indirect call -> direct call reta" "afdo"} } */
+/* { dg-final-use-autofdo { scan-ipa-dump "looks good" "afdo"} } */
+/* If we inlined reta->test->main, it will contian array[pos].  */
+/* { dg-final-use-autofdo { scan-ipa-dump "array.pos_" "afdo"} } */