[clang] [llvm] [HLSL] Implementation of dot intrinsic (PR #81190)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 23 16:13:53 PST 2024


================
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -verify-ignore-unexpected
+
+float test_no_second_arg ( float2 p0) {
+  return __builtin_hlsl_dot ( p0 );
+  // expected-error at -1 {{too few arguments to function call, expected 2, have 1}}
+}
+
+float test_too_many_arg ( float2 p0) {
+  return __builtin_hlsl_dot ( p0, p0, p0 );
+  // expected-error at -1 {{too many arguments to function call, expected 2, have 3}}
+}
+
+//NOTE: eventually behavior should match builtin
+float test_dot_no_second_arg ( float2 p0) {
+  return dot ( p0 );
+  // expected-error at -1 {{no matching function for call to 'dot'}}
+}
+
+float test_dot_vector_size_mismatch ( float3 p0, float2 p1 ) {
+  return dot ( p0, p1 );
+  // expected-warning at -1 {{implicit conversion truncates vector: 'float3' (aka 'vector<float, 3>') to 'float __attribute__((ext_vector_type(2)))' (vector of 2 'float' values)}}
+}
+
+float test_dot_builtin_vector_size_mismatch ( float3 p0, float2 p1 ) {
+  return __builtin_hlsl_dot ( p0, p1 );
+  // expected-error at -1 {{first two arguments to '__builtin_hlsl_dot' must have the same type}}
+}
+
+float test_dot_scalar_mismatch ( float p0, int p1 ) {
+  return dot ( p0, p1 );
+  // expected-error at -1 {{call to 'dot' is ambiguous}}
+}
+
+float test_dot_element_type_mismatch ( int2 p0, float2 p1 ) {
+  return dot ( p0, p1 );
+  // expected-error at -1 {{call to 'dot' is ambiguous}}
----------------
llvm-beanz wrote:

Can you add the cases like this that should work but fail to the XFAIL’d test case that has the other overload resolution bugs?

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


More information about the cfe-commits mailing list