Skip to content

Commit 1cdcec5

Browse files
authored
[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 <[email protected]>
1 parent 1cb12fa commit 1cdcec5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,7 @@ bool Compiler<Emitter>::VisitParenExpr(const ParenExpr *E) {
725725
template <class Emitter>
726726
bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
727727
// Need short-circuiting for these.
728-
if (BO->getType()->isVectorType())
729-
return this->VisitVectorBinOp(BO);
730-
if (BO->isLogicalOp())
728+
if (BO->isLogicalOp() && !BO->getType()->isVectorType())
731729
return this->VisitLogicalBinOp(BO);
732730

733731
const Expr *LHS = BO->getLHS();
@@ -746,6 +744,8 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
746744

747745
if (BO->getType()->isAnyComplexType())
748746
return this->VisitComplexBinOp(BO);
747+
if (BO->getType()->isVectorType())
748+
return this->VisitVectorBinOp(BO);
749749
if ((LHS->getType()->isAnyComplexType() ||
750750
RHS->getType()->isAnyComplexType()) &&
751751
BO->isComparisonOp())
@@ -1264,6 +1264,8 @@ bool Compiler<Emitter>::VisitComplexBinOp(const BinaryOperator *E) {
12641264

12651265
template <class Emitter>
12661266
bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
1267+
assert(!E->isCommaOp() &&
1268+
"Comma op should be handled in VisitBinaryOperator");
12671269
assert(E->getType()->isVectorType());
12681270
assert(E->getLHS()->getType()->isVectorType());
12691271
assert(E->getRHS()->getType()->isVectorType());

clang/test/Sema/fp16vec-sema.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
2+
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fsyntax-only -Wno-unused-value -verify %s
23

34
typedef __fp16 half4 __attribute__ ((vector_size (8)));
45
typedef float float4 __attribute__ ((vector_size (16)));

0 commit comments

Comments
 (0)