diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -12620,7 +12620,6 @@ bool areVectorTypesSameSize(QualType srcType, QualType destType); bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType); bool isLaxVectorConversion(QualType srcType, QualType destType); - bool areSameVectorElemTypes(QualType srcType, QualType destType); bool anyAltivecTypes(QualType srcType, QualType destType); /// type checking declaration initializers (C99 6.7.8) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -7987,30 +7987,24 @@ "expected at least one type to be a vector here"); bool IsSrcTyAltivec = - SrcTy->isVectorType() && (SrcTy->castAs()->getVectorKind() == - VectorType::AltiVecVector); + SrcTy->isVectorType() && ((SrcTy->castAs()->getVectorKind() == + VectorType::AltiVecVector) || + (SrcTy->castAs()->getVectorKind() == + VectorType::AltiVecBool) || + (SrcTy->castAs()->getVectorKind() == + VectorType::AltiVecPixel)); + bool IsDestTyAltivec = DestTy->isVectorType() && - (DestTy->castAs()->getVectorKind() == - VectorType::AltiVecVector); + ((DestTy->castAs()->getVectorKind() == + VectorType::AltiVecVector) || + (DestTy->castAs()->getVectorKind() == + VectorType::AltiVecBool) || + (DestTy->castAs()->getVectorKind() == + VectorType::AltiVecPixel)); return (IsSrcTyAltivec || IsDestTyAltivec); } -// This returns true if both vectors have the same element type. -bool Sema::areSameVectorElemTypes(QualType SrcTy, QualType DestTy) { - assert((DestTy->isVectorType() || SrcTy->isVectorType()) && - "expected at least one type to be a vector here"); - - uint64_t SrcLen, DestLen; - QualType SrcEltTy, DestEltTy; - if (!breakDownVectorType(SrcTy, SrcLen, SrcEltTy)) - return false; - if (!breakDownVectorType(DestTy, DestLen, DestEltTy)) - return false; - - return (SrcEltTy == DestEltTy); -} - /// Are the two types lax-compatible vector types? That is, given /// that one of them is a vector, do they have equal storage sizes, /// where the storage size is the number of elements times the element @@ -9848,7 +9842,7 @@ // change, so if we are converting between vector types where // at least one is an Altivec vector, emit a warning. if (anyAltivecTypes(RHSType, LHSType) && - !areSameVectorElemTypes(RHSType, LHSType)) + !Context.areCompatibleVectorTypes(RHSType, LHSType)) Diag(RHS.get()->getExprLoc(), diag::warn_deprecated_lax_vec_conv_all) << RHSType << LHSType; Kind = CK_BitCast; @@ -9864,7 +9858,9 @@ const VectorType *VecType = RHSType->getAs(); if (VecType && VecType->getNumElements() == 1 && isLaxVectorConversion(RHSType, LHSType)) { - if (VecType->getVectorKind() == VectorType::AltiVecVector) + if (VecType->getVectorKind() == VectorType::AltiVecVector || + VecType->getVectorKind() == VectorType::AltiVecBool || + VecType->getVectorKind() == VectorType::AltiVecPixel) Diag(RHS.get()->getExprLoc(), diag::warn_deprecated_lax_vec_conv_all) << RHSType << LHSType; ExprResult *VecExpr = &RHS; @@ -10813,7 +10809,7 @@ ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS; if (isLaxVectorConversion(OtherType, VecType)) { if (anyAltivecTypes(RHSType, LHSType) && - !areSameVectorElemTypes(RHSType, LHSType)) + !Context.areCompatibleVectorTypes(RHSType, LHSType)) Diag(Loc, diag::warn_deprecated_lax_vec_conv_all) << RHSType << LHSType; // If we're allowing lax vector conversions, only the total (data) size // needs to be the same. For non compound assignment, if one of the types is diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1770,7 +1770,7 @@ !ToType->hasAttr(attr::ArmMveStrictPolymorphism))) { if (S.isLaxVectorConversion(FromType, ToType) && S.anyAltivecTypes(FromType, ToType) && - !S.areSameVectorElemTypes(FromType, ToType) && + !S.Context.areCompatibleVectorTypes(FromType, ToType) && !InOverloadResolution && !CStyle) { S.Diag(From->getBeginLoc(), diag::warn_deprecated_lax_vec_conv_all) << FromType << ToType; diff --git a/clang/test/CodeGen/SystemZ/zvector.c b/clang/test/CodeGen/SystemZ/zvector.c --- a/clang/test/CodeGen/SystemZ/zvector.c +++ b/clang/test/CodeGen/SystemZ/zvector.c @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu z13 -fzvector -emit-llvm -o - -W -Wall -Werror %s | opt -S -passes=mem2reg | FileCheck %s +// RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu z13 -fzvector \ +// RUN: -emit-llvm -o - -W -Wall -Werror -Wno-error=deprecate-lax-vec-conv-all \ +// RUN: %s | opt -S -passes=mem2reg | FileCheck %s volatile vector signed char sc, sc2; volatile vector unsigned char uc, uc2; diff --git a/clang/test/CodeGen/SystemZ/zvector2.c b/clang/test/CodeGen/SystemZ/zvector2.c --- a/clang/test/CodeGen/SystemZ/zvector2.c +++ b/clang/test/CodeGen/SystemZ/zvector2.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu z14 -fzvector \ -// RUN: -O -emit-llvm -o - -W -Wall -Werror %s | FileCheck %s +// RUN: -O -emit-llvm -o - -W -Wall -Werror -Wno-error=deprecate-lax-vec-conv-all %s | FileCheck %s volatile vector float ff, ff2; volatile vector bool int bi;