[Bug c++/88601] We may consider adding __builtin_convertvector and __builtin_shufflevector for better compatibility with Clang

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon May 31 07:33:06 GMT 2021


--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:


commit r12-1128-gef8176e0fac935c095cc39f4ecdfd43cdb8cb3f3
Author: Richard Biener <rguenther@suse.de>
Date:   Fri May 21 11:33:30 2021 +0200

    c++/88601 - [C/C++] __builtin_shufflevector support

    This adds support for the clang __builtin_shufflevector extension to
    the C and C++ frontends.  The builtin is lowered to VEC_PERM_EXPR.
    Because VEC_PERM_EXPR does not support different sized vector inputs
    or result or the special permute index of -1 (don't-care)
    c_build_shufflevector applies lowering by widening inputs and output
    to the widest vector, replacing -1 by a defined index and
    subsetting the final vector if we produced a wider result than

    Code generation thus can be sub-optimal, followup patches will
    aim to fix that by recovering from part of the missing features
    during RTL expansion and by relaxing the constraints of the GIMPLE
    IL with regard to VEC_PERM_EXPR.

    2021-05-21  Richard Biener  <rguenther@suse.de>

            PR c++/88601
            * c-common.c: Include tree-vector-builder.h and
            (c_common_reswords): Add __builtin_shufflevector.
            (c_build_shufflevector): New funtion.
            * c-common.h (enum rid): Add RID_BUILTIN_SHUFFLEVECTOR.
            (c_build_shufflevector): Declare.

            * c-decl.c (names_builtin_p): Handle RID_BUILTIN_SHUFFLEVECTOR.
            * c-parser.c (c_parser_postfix_expression): Likewise.

            * cp-objcp-common.c (names_builtin_p): Handle
            * cp-tree.h (build_x_shufflevector): Declare.
            * parser.c (cp_parser_postfix_expression): Handle
            * pt.c (tsubst_copy_and_build): Handle IFN_SHUFFLEVECTOR.
            * typeck.c (build_x_shufflevector): Build either a lowered
            VEC_PERM_EXPR or an unlowered shufflevector via a temporary
            internal function IFN_SHUFFLEVECTOR.

            * internal-fn.c (expand_SHUFFLEVECTOR): Define.
            * internal-fn.def (SHUFFLEVECTOR): New.
            * internal-fn.h (expand_SHUFFLEVECTOR): Declare.
            * doc/extend.texi: Document __builtin_shufflevector.

            * c-c++-common/builtin-shufflevector-2.c: New testcase.
            * c-c++-common/torture/builtin-shufflevector-1.c: Likewise.
            * g++.dg/ext/builtin-shufflevector-1.C: Likewise.
            * g++.dg/ext/builtin-shufflevector-2.C: Likewise.

More information about the Gcc-bugs mailing list