Skip to content

Commit 700e632

Browse files
Alexandre Ramesfhahn
authored andcommitted
[Sema] Support Comma operator for fp16 vectors.
The current half vector was enforcing an assert expecting "(LHS is half vector) == (RHS is half vector)" for comma. Reviewed By: ahatanak, fhahn Differential Revision: https://reviews.llvm.org/D88265
1 parent 187686b commit 700e632

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13940,9 +13940,10 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
1394013940
// float vectors and truncating the result back to half vector. For now, we do
1394113941
// this only when HalfArgsAndReturn is set (that is, when the target is arm or
1394213942
// arm64).
13943-
assert(isVector(RHS.get()->getType(), Context.HalfTy) ==
13944-
isVector(LHS.get()->getType(), Context.HalfTy) &&
13945-
"both sides are half vectors or neither sides are");
13943+
assert(
13944+
(Opc == BO_Comma || isVector(RHS.get()->getType(), Context.HalfTy) ==
13945+
isVector(LHS.get()->getType(), Context.HalfTy)) &&
13946+
"both sides are half vectors or neither sides are");
1394613947
ConvertHalfVec =
1394713948
needsConversionOfHalfVec(ConvertHalfVec, Context, LHS.get(), RHS.get());
1394813949

clang/test/Sema/fp16vec-sema.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
22

33
typedef __fp16 half4 __attribute__ ((vector_size (8)));
44
typedef float float4 __attribute__ ((vector_size (16)));
@@ -28,6 +28,8 @@ void testFP16Vec(int c) {
2828
sv0 = hv0 >= hv1;
2929
sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
3030
sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
31+
hv0, 1;
32+
1, hv0;
3133

3234
// Implicit conversion between half vectors and float vectors are not allowed.
3335
hv0 = fv0; // expected-error{{assigning to}}

0 commit comments

Comments
 (0)