[clang] [clang][bytecode] Handle vector comma op in common way (PR #109827)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 24 09:36:50 PDT 2024
https://github.com/yronglin created https://github.com/llvm/llvm-project/pull/109827
None
>From 4454c5c75a5b3d0930a10d59a1715dea0fb7ed5e Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Wed, 25 Sep 2024 00:35:26 +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 | 6 ++++--
clang/test/Sema/fp16vec-sema.c | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 754cd0db9868b7..49543d8481e737 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -725,8 +725,6 @@ 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())
return this->VisitLogicalBinOp(BO);
@@ -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..1f6f523cf9eb58 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