[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #112400)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 11 14:35:11 PST 2024


================
@@ -1824,6 +1824,23 @@ static bool CheckAnyScalarOrVector(Sema *S, CallExpr *TheCall,
   return false;
 }
 
+static bool CheckNotScalarType(Sema *S, CallExpr *TheCall, QualType Scalar,
+                               unsigned ArgIndex) {
+  assert(TheCall->getNumArgs() >= ArgIndex);
+  QualType ArgType = TheCall->getArg(ArgIndex)->getType();
+  auto *VTy = ArgType->getAs<VectorType>();
+  // is the scalar or vector<scalar>
+  if (S->Context.hasSameUnqualifiedType(ArgType, Scalar) ||
+      (VTy &&
+       S->Context.hasSameUnqualifiedType(VTy->getElementType(), Scalar))) {
+    S->Diag(TheCall->getArg(0)->getBeginLoc(),
+            diag::err_typecheck_expect_scalar_or_vector_not_type)
+        << ArgType << Scalar;
+    return true;
+  }
+  return false;
+}
----------------
bogner wrote:

This function seems like it's being made generic in a way that isn't particularly useful. Do we have cases where we reject a single specific scalar type, and that that type is something other than bool?

Also, I find the error message kind of confusing:
```
invalid operand of type 'bool' where 'bool' or a vector of such type is not allowed
```
This is redundant, isn't it? What information is this providing that "invalid operand of type 'bool'" wouldn't?

https://github.com/llvm/llvm-project/pull/112400


More information about the cfe-commits mailing list