diff options
| author | Nico Weber <thakis@chromium.org> | 2020-06-08 06:45:21 -0400 |
|---|---|---|
| committer | Nico Weber <thakis@chromium.org> | 2020-06-08 06:45:21 -0400 |
| commit | abca3b7b2ce539ce22c9d3ebdd3cb6c02bb4c009 (patch) | |
| tree | fb9856baa6fdad3a81838c16924d87554ebe9be0 | |
| parent | 215914151e01adb785098c77aeae3afd99a558f5 (diff) | |
| download | llvm-abca3b7b2ce539ce22c9d3ebdd3cb6c02bb4c009.zip llvm-abca3b7b2ce539ce22c9d3ebdd3cb6c02bb4c009.tar.gz llvm-abca3b7b2ce539ce22c9d3ebdd3cb6c02bb4c009.tar.bz2 | |
Revert "[clang] Implement VectorType logic not operator."
This reverts commit a0de3335edcf19305dad592d21ebe402825184f6.
Breaks check-clang on Windows, see e.g.
https://reviews.llvm.org/D80979#2078750 (but fails on all
other Windows bots too).
| -rw-r--r-- | clang/docs/LanguageExtensions.rst | 3 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 11 | ||||
| -rw-r--r-- | clang/test/CodeGen/vector-logic-not.cpp | 21 | ||||
| -rw-r--r-- | clang/test/Sema/vector-gcc-compat.cpp | 2 |
5 files changed, 6 insertions, 35 deletions
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 06ecc18..ba0a7d9 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -475,7 +475,7 @@ unary operators +, -- yes yes yes -- +,--,*,/,% yes yes yes -- bitwise operators &,|,^,~ yes yes yes -- >>,<< yes yes yes -- -!, &&, || yes -- yes -- +!, &&, || yes -- yes [#]_ -- ==, !=, >, <, >=, <= yes yes yes -- = yes yes yes yes ?: [#]_ yes -- yes -- @@ -488,6 +488,7 @@ const_cast no no no no See also :ref:`langext-__builtin_shufflevector`, :ref:`langext-__builtin_convertvector`. +.. [#] unary operator ! is not implemented, however && and || are. .. [#] ternary operator(?:) has different behaviors depending on condition operand's vector type. If the condition is a GNU vector (i.e. __vector_size__), it's only available in C++ and uses normal bool conversions (that is, != 0). diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index b2bc38b..4e61349c 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -2762,9 +2762,7 @@ Value *ScalarExprEmitter::VisitUnaryNot(const UnaryOperator *E) { Value *ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *E) { // Perform vector logical not on comparison with zero vector. - if (E->getType()->isVectorType() && - E->getType()->castAs<VectorType>()->getVectorKind() == - VectorType::GenericVector) { + if (E->getType()->isExtVectorType()) { Value *Oper = Visit(E->getSubExpr()); Value *Zero = llvm::Constant::getNullValue(Oper->getType()); Value *Result; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 4bec413..45c1ace 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -14484,16 +14484,9 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, // Vector logical not returns the signed variant of the operand type. resultType = GetSignedVectorType(resultType); break; - } else if (Context.getLangOpts().CPlusPlus && resultType->isVectorType()) { - const VectorType *VTy = resultType->castAs<VectorType>(); - if (VTy->getVectorKind() != VectorType::GenericVector) - return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr) - << resultType << Input.get()->getSourceRange()); - - // Vector logical not returns the signed variant of the operand type. - resultType = GetSignedVectorType(resultType); - break; } else { + // FIXME: GCC's vector extension permits the usage of '!' with a vector + // type in C++. We should allow that here too. return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr) << resultType << Input.get()->getSourceRange()); } diff --git a/clang/test/CodeGen/vector-logic-not.cpp b/clang/test/CodeGen/vector-logic-not.cpp deleted file mode 100644 index 2ac0267..0000000 --- a/clang/test/CodeGen/vector-logic-not.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s - -typedef __attribute__((__vector_size__(16))) float float4; -typedef __attribute__((__vector_size__(16))) int int4; -typedef __attribute__((__vector_size__(16))) unsigned int uint4; - -// CHECK: @_Z5test1Dv4_j -int4 test1(uint4 V0) { - // CHECK: [[CMP0:%.*]] = icmp eq <4 x i32> [[V0:%.*]], zeroinitializer - // CHECK-NEXT: [[V1:%.*]] = sext <4 x i1> [[CMP0]] to <4 x i32> - int4 V = !V0; - return V; -} - -// CHECK: @_Z5test2Dv4_fS_ -int4 test2(float4 V0, float4 V1) { - // CHECK: [[CMP0:%.*]] = fcmp oeq <4 x float> [[V0:%.*]], zeroinitializer - // CHECK-NEXT: [[V1:%.*]] = sext <4 x i1> [[CMP0]] to <4 x i32> - int4 V = !V0; - return V; -} diff --git a/clang/test/Sema/vector-gcc-compat.cpp b/clang/test/Sema/vector-gcc-compat.cpp index cb65476..41d50c1 100644 --- a/clang/test/Sema/vector-gcc-compat.cpp +++ b/clang/test/Sema/vector-gcc-compat.cpp @@ -83,7 +83,7 @@ void logicTest(void) { v2i64 v2i64_c = (v2i64){3, 1}; // expected-warning {{compound literals are a C99-specific feature}} v2i64 v2i64_r; - v2i64_r = !v2i64_a; + v2i64_r = !v2i64_a; // expected-error {{invalid argument type 'v2i64' (vector of 2 'long long' values) to unary expression}} v2i64_r = ~v2i64_a; v2i64_r = v2i64_a ? v2i64_b : v2i64_c; |
