https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114232

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Yeah, indeed, the optabs enable flags are cached in the optimization node, so
it is ok
to check the optimization flags in there, or target flags as well, but
optimize_function_for_*_p is not, because it depends also on
node->count/node->frequency of the current function but multiple functions can
have the same optimization node/target node combo.
Seems i386 is the only backend which does something like that.
I believe this has been fixed in the backend in the past already, see e.g.
PR92791
While
      if (opts != optimization_default_node)
        {
          init_tree_optimization_optabs (opts);
          if (TREE_OPTIMIZATION_OPTABS (opts))
            this_fn_optabs = (struct target_optabs *)
              TREE_OPTIMIZATION_OPTABS (opts);
        }
in invoke_set_current_function_hook maybe (hopefully) makes stuff work right
for the different options, that certainly doesn't account for
node->function/node->count.

Seems various backends use e.g. optimize_size or !optimize_size or optimize > 0
etc. in
insn-flags.h, so perhaps change optimize_function_for_size_p (cfun) to
optimize_size?

Reply via email to