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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, I see, expression_expensive_p is called, but number_of_iterations_popcount
when creating a CALL_EXPR only cares about TYPE_PRECISION and happily creates
__builtin_popcountl with unsigned long long argument because it has the same
precision.  tree_builtin_call_types_compatible_p says it is not valid builtin
call and so we don't consider it expensive.

Either we make number_of_iterations_popcount more accurate on the types, or
better in tree_builtin_call_types_compatible_p use something like:
  bool in_gimple_form = (cfun && (cfun->curr_properties & PROP_gimple)) != 0;
and if in_gimple_form, use useless_type_conversion_p instead of the
TYPE_MAIN_VARIANT / tree_nop_conversion_p checks.
That is my strong preference...

What do you think?

Reply via email to