Skip to content

Commit 8eaea32

Browse files
committed
address pr comments
1 parent f648f46 commit 8eaea32

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20352,16 +20352,10 @@ Value *CodeGenFunction::EmitSPIRVBuiltinExpr(unsigned BuiltinID,
2035220352
E->getArg(1)->getType()->hasFloatingRepresentation() &&
2035320353
E->getArg(2)->getType()->hasFloatingRepresentation() &&
2035420354
"SmoothStep operands must have a float representation");
20355-
assert((E->getArg(0)->getType()->isScalarType() ||
20356-
E->getArg(0)->getType()->isVectorType()) &&
20357-
(E->getArg(1)->getType()->isScalarType() ||
20358-
E->getArg(1)->getType()->isVectorType()) &&
20359-
(E->getArg(2)->getType()->isScalarType() ||
20360-
E->getArg(2)->getType()->isVectorType()) &&
20361-
"SmoothStep operands must be a scalar or vector");
2036220355
return Builder.CreateIntrinsic(
2036320356
/*ReturnType=*/Min->getType(), Intrinsic::spv_smoothstep,
20364-
ArrayRef<Value *>{Min, Max, X}, nullptr, "spv.smoothstep");
20357+
ArrayRef<Value *>{Min, Max, X}, /*FMFSource=*/nullptr,
20358+
"spv.smoothstep");
2036520359
}
2036620360
}
2036720361
return nullptr;

clang/lib/Sema/SemaSPIRV.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,33 +105,41 @@ bool SemaSPIRV::CheckSPIRVBuiltinFunctionCall(unsigned BuiltinID,
105105
if (SemaRef.checkArgCount(TheCall, 3))
106106
return true;
107107

108+
// check if the all arguments have floating representation
108109
ExprResult A = TheCall->getArg(0);
109110
QualType ArgTyA = A.get()->getType();
110-
auto *VTyA = ArgTyA->getAs<VectorType>();
111-
if (!(ArgTyA->isScalarType() || VTyA)) {
111+
if (!ArgTyA->hasFloatingRepresentation()) {
112112
SemaRef.Diag(A.get()->getBeginLoc(),
113-
diag::err_typecheck_expect_any_scalar_or_vector)
114-
<< ArgTyA << 1;
113+
diag::err_typecheck_convert_incompatible)
114+
<< ArgTyA << SemaRef.Context.FloatTy << 1 << 0 << 0;
115115
return true;
116116
}
117117

118118
ExprResult B = TheCall->getArg(1);
119119
QualType ArgTyB = B.get()->getType();
120-
auto *VTyB = ArgTyB->getAs<VectorType>();
121-
if (!(ArgTyB->isScalarType() || VTyB)) {
120+
if (!ArgTyB->hasFloatingRepresentation()) {
122121
SemaRef.Diag(A.get()->getBeginLoc(),
123-
diag::err_typecheck_expect_any_scalar_or_vector)
124-
<< ArgTyB << 1;
122+
diag::err_typecheck_convert_incompatible)
123+
<< ArgTyB << SemaRef.Context.FloatTy << 1 << 0 << 0;
125124
return true;
126125
}
127126

128127
ExprResult C = TheCall->getArg(2);
129128
QualType ArgTyC = C.get()->getType();
130-
auto *VTyC = ArgTyC->getAs<VectorType>();
131-
if (!(ArgTyC->isScalarType() || VTyC)) {
129+
if (!ArgTyC->hasFloatingRepresentation()) {
132130
SemaRef.Diag(A.get()->getBeginLoc(),
133-
diag::err_typecheck_expect_any_scalar_or_vector)
134-
<< ArgTyC << 1;
131+
diag::err_typecheck_convert_incompatible)
132+
<< ArgTyC << SemaRef.Context.FloatTy << 1 << 0 << 0;
133+
return true;
134+
}
135+
136+
// check if all arguments are of the same type
137+
if (!(SemaRef.getASTContext().hasSameUnqualifiedType(ArgTyA, ArgTyB) &&
138+
SemaRef.getASTContext().hasSameUnqualifiedType(ArgTyA, ArgTyC))) {
139+
SemaRef.Diag(TheCall->getBeginLoc(),
140+
diag::err_vec_builtin_incompatible_vector)
141+
<< TheCall->getDirectCallee() << /*useAllTerminology*/ true
142+
<< SourceRange(A.get()->getBeginLoc(), C.get()->getEndLoc());
135143
return true;
136144
}
137145

0 commit comments

Comments
 (0)