[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


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

--- 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>:

https://gcc.gnu.org/g:ef8176e0fac935c095cc39f4ecdfd43cdb8cb3f3

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
    desired.

    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
    gcc/c-family/
            * c-common.c: Include tree-vector-builder.h and
            vec-perm-indices.h.
            (c_common_reswords): Add __builtin_shufflevector.
            (c_build_shufflevector): New funtion.
            * c-common.h (enum rid): Add RID_BUILTIN_SHUFFLEVECTOR.
            (c_build_shufflevector): Declare.

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

    gcc/cp/
            * cp-objcp-common.c (names_builtin_p): Handle
            RID_BUILTIN_SHUFFLEVECTOR.
            * cp-tree.h (build_x_shufflevector): Declare.
            * parser.c (cp_parser_postfix_expression): Handle
            RID_BUILTIN_SHUFFLEVECTOR.
            * 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.

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

    gcc/testsuite/
            * 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