[clang] [clang][bytecode] Handle vector comma op (PR #109827)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 24 16:45:07 PDT 2024
https://github.com/yronglin updated https://github.com/llvm/llvm-project/pull/109827
>From fcd804f4ae81b17d0afe94940042deb8a1568197 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Wed, 25 Sep 2024 07:44:40 +0800
Subject: [PATCH] [clang][bytecode] Handle vector comma op in common way
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
clang/lib/AST/ByteCode/Compiler.cpp | 8 +++++---
clang/test/Sema/fp16vec-sema.c | 1 +
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 754cd0db9868b7..b531a2e6491e03 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