On Wed, Sep 9, 2026 at 5:06 AM Richard Biener <[email protected]> wrote:
>
> We preserve those casts to eventually be able to canonicalize
> function pointer operands in comparisons via the
> canonicalize_funcptr_for_compare named pattern which is
> only implemented for hppa. The following elides this after
> exposing the canonicalization in the IL with the earlier patch.
Ok, once the other patch has been tested/approved on hppa.
>
> * gimple-expr.cc (useless_type_conversion_p): Do not
> preserve casts to function pointer types.
> * tree-cfg.cc (verify_gimple_call): Allow any pointer
> type as function pointer argument on calls.
> ---
> gcc/gimple-expr.cc | 4 ----
> gcc/tree-cfg.cc | 7 ++-----
> 2 files changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/gcc/gimple-expr.cc b/gcc/gimple-expr.cc
> index 3b8726ded4d..32a7b75d205 100644
> --- a/gcc/gimple-expr.cc
> +++ b/gcc/gimple-expr.cc
> @@ -75,10 +75,6 @@ useless_type_conversion_p (tree outer_type, tree
> inner_type)
> if (TYPE_ADDR_SPACE (TREE_TYPE (outer_type))
> != TYPE_ADDR_SPACE (TREE_TYPE (inner_type)))
> return false;
> - /* Do not lose casts to function pointer types. */
> - if (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (outer_type))
> - && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (inner_type)))
> - return false;
> }
>
> /* From now on qualifiers on value types do not matter. */
> diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
> index ba1d4a125ad..c7f2f987b25 100644
> --- a/gcc/tree-cfg.cc
> +++ b/gcc/tree-cfg.cc
> @@ -3373,12 +3373,9 @@ verify_gimple_call (gcall *stmt)
> return true;
> }
>
> - if (fn
> - && (!POINTER_TYPE_P (TREE_TYPE (fn))
> - || (TREE_CODE (TREE_TYPE (TREE_TYPE (fn))) != FUNCTION_TYPE
> - && TREE_CODE (TREE_TYPE (TREE_TYPE (fn))) != METHOD_TYPE)))
> + if (fn && !POINTER_TYPE_P (TREE_TYPE (fn)))
> {
> - error ("non-function in gimple call");
> + error ("non-pointer in gimple call");
> return true;
> }
>
> --
> 2.51.0