[clang] 02a71b0 - [PowerPC] Include vector bool and pixel when emitting lax warning
Maryam Moghadas via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 21 14:26:24 PST 2023
Author: Maryam Moghadas
Date: 2023-02-21T22:26:18Z
New Revision: 02a71b05fc67326d8ea336aa8ef934de0575be39
URL: https://github.com/llvm/llvm-project/commit/02a71b05fc67326d8ea336aa8ef934de0575be39
DIFF: https://github.com/llvm/llvm-project/commit/02a71b05fc67326d8ea336aa8ef934de0575be39.diff
LOG: [PowerPC] Include vector bool and pixel when emitting lax warning
This patch is to fix some missing lax-vector-conversion warnings including
cases that involve vector bool and vector pixel, also to fix the vector
compatibility check for the warnings.
Differential Revision: https://reviews.llvm.org/D143210
Added:
Modified:
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/CodeGen/SystemZ/zvector.c
clang/test/CodeGen/SystemZ/zvector2.c
Removed:
################################################################################
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 176d92ae6fb1b..ecc031ce116e6 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12620,7 +12620,6 @@ class Sema final {
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
index 12c02e531da3e..af88d460137ae 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7987,30 +7987,24 @@ bool Sema::anyAltivecTypes(QualType SrcTy, QualType DestTy) {
"expected at least one type to be a vector here");
bool IsSrcTyAltivec =
- SrcTy->isVectorType() && (SrcTy->castAs<VectorType>()->getVectorKind() ==
- VectorType::AltiVecVector);
+ SrcTy->isVectorType() && ((SrcTy->castAs<VectorType>()->getVectorKind() ==
+ VectorType::AltiVecVector) ||
+ (SrcTy->castAs<VectorType>()->getVectorKind() ==
+ VectorType::AltiVecBool) ||
+ (SrcTy->castAs<VectorType>()->getVectorKind() ==
+ VectorType::AltiVecPixel));
+
bool IsDestTyAltivec = DestTy->isVectorType() &&
- (DestTy->castAs<VectorType>()->getVectorKind() ==
- VectorType::AltiVecVector);
+ ((DestTy->castAs<VectorType>()->getVectorKind() ==
+ VectorType::AltiVecVector) ||
+ (DestTy->castAs<VectorType>()->getVectorKind() ==
+ VectorType::AltiVecBool) ||
+ (DestTy->castAs<VectorType>()->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 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS,
// 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 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS,
const VectorType *VecType = RHSType->getAs<VectorType>();
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 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
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
index d68337a26d975..a4485be3b0932 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1770,7 +1770,7 @@ static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType,
!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
index 50fae1184d238..33fde545b9d4e 100644
--- 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
index 36cbf228feac8..93fb1f5434305 100644
--- 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;
More information about the cfe-commits
mailing list