llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Joseph Huber (jhuber6) <details> <summary>Changes</summary> Summary: The `__builtin_shufflevector` call would return a GCC vector in all cases where the vector type was increased. Change this to preserve whether or not this was an extended vector. Fixes: https://github.com/llvm/llvm-project/issues/107981 --- Full diff: https://github.com/llvm/llvm-project/pull/154817.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaChecking.cpp (+5-2) - (modified) clang/test/AST/ByteCode/constexpr-vectors.cpp (+6-1) ``````````diff diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 2944c1a09b32c..c39236cd5f8f8 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -5601,8 +5601,11 @@ ExprResult Sema::BuiltinShuffleVector(CallExpr *TheCall) { TheCall->getArg(1)->getEndLoc())); } else if (numElements != numResElements) { QualType eltType = LHSType->castAs<VectorType>()->getElementType(); - resType = - Context.getVectorType(eltType, numResElements, VectorKind::Generic); + if (resType->isExtVectorType()) + resType = Context.getExtVectorType(eltType, numResElements); + else + resType = + Context.getVectorType(eltType, numResElements, VectorKind::Generic); } } diff --git a/clang/test/AST/ByteCode/constexpr-vectors.cpp b/clang/test/AST/ByteCode/constexpr-vectors.cpp index f19adad3323f2..81ec6aac4bee3 100644 --- a/clang/test/AST/ByteCode/constexpr-vectors.cpp +++ b/clang/test/AST/ByteCode/constexpr-vectors.cpp @@ -15,7 +15,6 @@ using FourFloatsExtVec __attribute__((ext_vector_type(4))) = float; using FourDoublesExtVec __attribute__((ext_vector_type(4))) = double; using FourI128ExtVec __attribute__((ext_vector_type(4))) = __int128; - // Next a series of tests to make sure these operations are usable in // constexpr functions. Template instantiations don't emit Winvalid-constexpr, // so we have to do these as macros. @@ -875,3 +874,9 @@ void BoolVecUsage() { constexpr auto k = ~FourBoolsExtVec{true, false, true, false}; static_assert(k[0] == false && k[1] == true && k[2] == false && k[3] == true, ""); } + +using EightBoolsExtVec __attribute__((ext_vector_type(8))) = bool; +void BoolVecShuffle() { + constexpr EightBoolsExtVec a = __builtin_shufflevector( + FourBoolsExtVec{}, FourBoolsExtVec{}, 0, 1, 2, 3, 4, 5, 6, 7); +} `````````` </details> https://github.com/llvm/llvm-project/pull/154817 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits