https://gcc.gnu.org/g:3d1d893a00d6a46e8f090ad29715693b6c04a78f

commit r16-1543-g3d1d893a00d6a46e8f090ad29715693b6c04a78f
Author: Jan Hubicka <hubi...@ucw.cz>
Date:   Tue Jun 17 15:43:13 2025 +0200

    Add testcase for AFDO early inlining and indirect call promotion
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/tree-prof/afdo-vpt-earlyinline.c: New test.

Diff:
---
 .../gcc.dg/tree-prof/afdo-vpt-earlyinline.c        | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)

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
index 000000000000..3b51ea9f8a9d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/afdo-vpt-earlyinline.c
@@ -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"} } */

Reply via email to