On Tue, Sep 23, 2025 at 11:22 PM Richard Biener <[email protected]> wrote: > > On Tue, Sep 23, 2025 at 7:09 PM Andrew Pinski > <[email protected]> wrote: > > > > This moves the removal of the ASSUME internal function to gimple fold. > > The only thing is fab for -Og support until fab is removed either needs to > > stay > > or changed over to a fold_stmt. I decided to change over to a fold_stmt for > > internal function calls. I am almost positive this won't change much either > > way. > > For -Og we should be able to set PROP_last_full_fold before CCP?
Yes, I think for -Og, we could set PROP_last_full_fold at the beginning of the pass_all_optimizations_g which would be before ccp. Note the change for internal functions to use fold_stmt is also just temporary before I finish moving everything away from fold_builtins. I have the set of patches in testing which finishes that up. So temporary is max a week or 2 depending on reviews on them during the Cauldron. So the current -Og pipeline is: ``` NEXT_PASS (pass_ccp, true /* nonzero_p */); NEXT_PASS (pass_post_ipa_warn); NEXT_PASS (pass_object_sizes); /* Fold remaining builtins. */ NEXT_PASS (pass_fold_builtins); NEXT_PASS (pass_strlen); /* Copy propagation also copy-propagates constants, this is necessary to forward object-size and builtin folding results properly. */ NEXT_PASS (pass_copy_prop); ``` I was thinking we change it to: ``` NEXT_PASS (pass_ccp, true /* nonzero_p */); NEXT_PASS (pass_post_ipa_warn); NEXT_PASS (pass_object_sizes); NEXT_PASS (pass_strlen); /* Fold remaining builtins and do a copy-prop. */ NEXT_PASS (pass_forwprop); ``` This should give a decent balance of compile time and optimizations. And we still removed a pass. Thanks, Andrew > > > Bootstrapped and tested on x86_64-linux-gnu. > > > > PR tree-optimization/121762 > > gcc/ChangeLog: > > > > * gimple-fold.cc (gimple_fold_call): Remove ASSUME internal function > > calls when PROP_last_full_fold is set. > > * tree-ssa-ccp.cc (pass_fold_builtins::execute): Handling folding > > of all internal functions. > > > > Signed-off-by: Andrew Pinski <[email protected]> > > --- > > gcc/gimple-fold.cc | 6 ++++++ > > gcc/tree-ssa-ccp.cc | 29 +++++++++++++++++++++++++++-- > > 2 files changed, 33 insertions(+), 2 deletions(-) > > > > diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc > > index 403fbe09102..84eb998d764 100644 > > --- a/gcc/gimple-fold.cc > > +++ b/gcc/gimple-fold.cc > > @@ -5883,6 +5883,12 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool > > inplace) > > tree overflow = NULL_TREE; > > switch (gimple_call_internal_fn (stmt)) > > { > > + case IFN_ASSUME: > > + /* Remove .ASSUME calls during the last fold since it is no > > + longer needed. */ > > + if (cfun->curr_properties & PROP_last_full_fold) > > + replace_call_with_value (gsi, NULL_TREE); > > + break; > > case IFN_BUILTIN_EXPECT: > > result = fold_builtin_expect (gimple_location (stmt), > > gimple_call_arg (stmt, 0), > > diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc > > index 070289ca9f0..d2c133345cd 100644 > > --- a/gcc/tree-ssa-ccp.cc > > +++ b/gcc/tree-ssa-ccp.cc > > @@ -4297,9 +4297,34 @@ pass_fold_builtins::execute (function *fun) > > > > callee = gimple_call_fndecl (stmt); > > if (!callee > > - && gimple_call_internal_p (stmt, IFN_ASSUME)) > > + && gimple_call_internal_p (stmt)) > > { > > - gsi_remove (&i, true); > > + if (!fold_stmt (&i)) > > + { > > + gsi_next (&i); > > + continue; > > + } > > + if (dump_file && (dump_flags & TDF_DETAILS)) > > + { > > + fprintf (dump_file, "Simplified\n "); > > + print_gimple_stmt (dump_file, stmt, 0, dump_flags); > > + } > > + > > + old_stmt = stmt; > > + stmt = gsi_stmt (i); > > + update_stmt (stmt); > > + > > + if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt) > > + && gimple_purge_dead_eh_edges (bb)) > > + cfg_changed = true; > > + > > + if (dump_file && (dump_flags & TDF_DETAILS)) > > + { > > + fprintf (dump_file, "to\n "); > > + print_gimple_stmt (dump_file, stmt, 0, dump_flags); > > + fprintf (dump_file, "\n"); > > + } > > + gsi_next (&i); > > continue; > > } > > if (!callee || !fndecl_built_in_p (callee, BUILT_IN_NORMAL)) > > -- > > 2.43.0 > >
