[clang] 1cdcec5 - [clang][bytecode] Handle vector comma op (#109827)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 24 23:09:09 PDT 2024
Author: yronglin
Date: 2024-09-25T14:09:06+08:00
New Revision: 1cdcec5884fb99d921800197e0863329de6b10ee
URL: https://github.com/llvm/llvm-project/commit/1cdcec5884fb99d921800197e0863329de6b10ee
DIFF: https://github.com/llvm/llvm-project/commit/1cdcec5884fb99d921800197e0863329de6b10ee.diff
LOG: [clang][bytecode] Handle vector comma op (#109827)
Currently we were not handle comma op for vector operands, after this
patch, we handle the comma op for vector operands with common way.
Signed-off-by: yronglin <yronglin777 at gmail.com>
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/Sema/fp16vec-sema.c
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 785918846976d4..e54b6568d7060b 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -725,9 +725,7 @@ bool Compiler<Emitter>::VisitParenExpr(const ParenExpr *E) {
template <class Emitter>
bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
// Need short-circuiting for these.
- if (BO->getType()->isVectorType())
- return this->VisitVectorBinOp(BO);
- if (BO->isLogicalOp())
+ if (BO->isLogicalOp() && !BO->getType()->isVectorType())
return this->VisitLogicalBinOp(BO);
const Expr *LHS = BO->getLHS();
@@ -746,6 +744,8 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
if (BO->getType()->isAnyComplexType())
return this->VisitComplexBinOp(BO);
+ if (BO->getType()->isVectorType())
+ return this->VisitVectorBinOp(BO);
if ((LHS->getType()->isAnyComplexType() ||
RHS->getType()->isAnyComplexType()) &&
BO->isComparisonOp())
@@ -1264,6 +1264,8 @@ bool Compiler<Emitter>::VisitComplexBinOp(const BinaryOperator *E) {
template <class Emitter>
bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
+ assert(!E->isCommaOp() &&
+ "Comma op should be handled in VisitBinaryOperator");
assert(E->getType()->isVectorType());
assert(E->getLHS()->getType()->isVectorType());
assert(E->getRHS()->getType()->isVectorType());
diff --git a/clang/test/Sema/fp16vec-sema.c b/clang/test/Sema/fp16vec-sema.c
index 80936cd622f7cd..89f01c6dcf47b6 100644
--- a/clang/test/Sema/fp16vec-sema.c
+++ b/clang/test/Sema/fp16vec-sema.c
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fsyntax-only -Wno-unused-value -verify %s
typedef __fp16 half4 __attribute__ ((vector_size (8)));
typedef float float4 __attribute__ ((vector_size (16)));
More information about the cfe-commits
mailing list