https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117984
Bug ID: 117984 Summary: missed IPA constant propagation Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- In the following se should optimize away prinf even if the bar call is commented out. However we don't do that at all since jump function is missing: struct a {int a,b;}; void bar (struct a *); __attribute ((noinline)) static void bar2 (int a) { if (a) __builtin_printf ("optimize me away"); } __attribute ((noinline)) static void foo(struct a a) { //bar (&a); bar2 (a.a); } void test() { foo ({0,1}); } We get: Jump functions: Jump functions of caller int __builtin_printf(const char*, ...)/3: Jump functions of caller void test()/2: callsite void test()/2 -> void foo(a)/1 : param 0: UNKNOWN Aggregate passed by value: offset: 0, type: int, CONST: 0 offset: 32, type: int, CONST: 1 Unknown VR Jump functions of caller void foo(a)/1: callsite void foo(a)/1 -> void bar2(int)/0 : param 0: UNKNOWN Unknown VR Jump functions of caller void bar2(int)/0: callsite void bar2(int)/0 -> int __builtin_printf(const char*, ...)/3 : no arg info Modification phase of node void bar2(int)/0 __attribute__((noinline)) void bar2 (int a) { <bb 2> [local count: 1073741824]: if (a_2(D) != 0) goto <bb 3>; [33.00%] else goto <bb 4>; [67.00%] <bb 3> [local count: 354334800]: __builtin_printf ("optimize me away"); <bb 4> [local count: 1073741824]: return; } ;; Function foo.constprop.isra (_ZL3foo1a.constprop.0.isra.0, funcdef_no=4, decl_uid=2828, cgraph_uid=6, symbol_order=5) Modification phase of node void foo(a)/5 __attribute__((noinline)) void foo.constprop.isra () { struct a a; int removed_ipa_cp.7; int removed_ipa_cp.6; int _1; <bb 4> [local count: 1073741824]: removed_ipa_cp.7_2 = 1; removed_ipa_cp.6_3 = 0; <bb 2> [local count: 1073741824]: <bb 3> [local count: 1073741824]: _1 = removed_ipa_cp.6_3; bar2 (_1); return; } ;; Function test (_Z4testv, funcdef_no=2, decl_uid=2805, cgraph_uid=3, symbol_order=2) Modification phase of node void test()/2 void test () { struct a D.2817; <bb 2> [local count: 1073741824]: D.2817.a = 0; D.2817.b = 1; foo (D.2817); return; } So we propagate to test->foo but not foo->bar. What is also odd is that we don't optimize away the unused parameter of foo.