https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127171
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jan Hubicka <[email protected]>: https://gcc.gnu.org/g:9961d5f117c4afe323dc1be8b0df9031b28265e4 commit r17-6280-g9961d5f117c4afe323dc1be8b0df9031b28265e4 Author: Jan Hubicka <[email protected]> Date: Sat Nov 14 23:33:22 2026 +0100 Improve nonconstant predicates and PHI walking for unknown-offset loads This makes the testcase from PR ipa/127171 to be analyzed correctly when dispatch_impl is marked always_inline. There are few changes needed: 1) Extend will_be_nonconstant_predicate to handle comparisons and switches on aggregate parameter loads with unknown_offset or maybe_modified, and use it in phi_result_unknown_predicate for both GIMPLE_COND and GIMPLE_SWITCH. Fix the inverted unknown_offset check when simplifying complementary clauses in ipa_predicate::add_clause. 2) Ignore unreachable null-pointer operands when walking pointer definitions in ipa_load_from_parm_agg_unknown_offset when -fdelete-null-pointer-checks is active and address zero is invalid 3) Raise the default -param=ipa-jump-function-lookups limit from 8 to 64 so deeper pointer chains across loops and inlined helpers can be tracked. There is quite complex loop and we need to skip all PHIs of the parameter. If this becomes a problem, it is also possible to remember the results of earlier analysis. Finally I also noticed last minute change bug I introduced to ipa-predicate and fixed it too. For actual testcase to work we sadly still need more work, since display_impl takes the pointer to pointer as parameter and adjust it. We don't have return functions and here we would need return function for value passed by refernece. gcc/ChangeLog: PR ipa/127171 * ipa-fnsummary.cc (compute_switch_edge_predicates): Break out out from set_switch_stmt_execution_predicate; support computing per-edge predicates for nonconstant evaluation. (set_switch_stmt_execution_predicate): Use compute_switch_edge_predicates. (will_be_nonconstant_predicate): Handle comparisons and switches on aggregate loads with unknown_offset or maybe_modified. (phi_result_unknown_predicate): Handle GIMPLE_SWITCH and use will_be_nonconstant_predicate. * ipa-predicate.cc (ipa_predicate::add_clause): Fix inverted unknown_offset check when matching complementary conditions. * ipa-prop.cc (ipa_load_from_parm_agg_unknown_offset): Skip null pointer operands when null pointer dereferences are invalid and require matching address spaces on pointer conversions. * params.opt (-param=ipa-jump-function-lookups=): Increase default from 8 to 64. gcc/testsuite/ChangeLog: PR ipa/127171 * gcc.dg/ipa/fnsummary-11.c: New test. * gcc.dg/ipa/fnsummary-12.c: New test. * gcc.dg/ipa/fnsummary-13.c: New test. Assisted-by: Google Carbon
