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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>:

https://gcc.gnu.org/g:00eab0c654e09c8a0f1b1a3b1c7bff8764e64991

commit r13-1647-g00eab0c654e09c8a0f1b1a3b1c7bff8764e64991
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Tue Jul 12 14:09:44 2022 +0100

    Add internal functions for iround etc. [PR106253]

    The PR is about the aarch64 port using an ACLE built-in function
    to vectorise a scalar function call, even though the ECF_* flags for
    the ACLE function didn't match the ECF_* flags for the scalar call.

    To some extent that kind of difference is inevitable, since the
    ACLE intrinsics are supposed to follow the behaviour of the
    underlying instruction as closely as possible.  Also, using
    target-specific builtins has the drawback of limiting further
    gimple optimisation, since the gimple optimisers won't know what
    the function does.

    We handle several other maths functions, including round, floor
    and ceil, by defining directly-mapped internal functions that
    are linked to the associated built-in functions.  This has two
    main advantages:

    - it means that, internally, we are not restricted to the set of
      scalar types that happen to have associated C/C++ functions

    - the functions (and thus the underlying optabs) extend naturally
      to vectors

    This patch takes the same approach for the remaining functions
    handled by aarch64_builtin_vectorized_function.

    gcc/
            PR target/106253
            * predict.h (insn_optimization_type): Declare.
            * predict.cc (insn_optimization_type): New function.
            * internal-fn.def (IFN_ICEIL, IFN_IFLOOR, IFN_IRINT, IFN_IROUND)
            (IFN_LCEIL, IFN_LFLOOR, IFN_LRINT, IFN_LROUND, IFN_LLCEIL)
            (IFN_LLFLOOR, IFN_LLRINT, IFN_LLROUND): New internal functions.
            * internal-fn.cc (unary_convert_direct): New macro.
            (expand_convert_optab_fn): New function.
            (expand_unary_convert_optab_fn): New macro.
            (direct_unary_convert_optab_supported_p): Likewise.
            * optabs.cc (expand_sfix_optab): Pass insn_optimization_type to
            convert_optab_handler.
            * config/aarch64/aarch64-protos.h
            (aarch64_builtin_vectorized_function): Delete.
            * config/aarch64/aarch64-builtins.cc
            (aarch64_builtin_vectorized_function): Delete.
            * config/aarch64/aarch64.cc
            (TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Delete.
            * config/i386/i386.cc (ix86_optab_supported_p): Handle
lround_optab.
            * config/i386/i386.md (lround<X87MODEF:mode><SWI248x:mode>2):
Remove
            optimize_insn_for_size_p test.

    gcc/testsuite/
            PR target/106253
            * gcc.target/aarch64/vect_unary_1.c: Add tests for iroundf,
            llround, iceilf, llceil, ifloorf, llfloor, irintf and llrint.
            * gfortran.dg/vect/pr106253.f: New test.

Reply via email to