[clang] [llvm] [Matrix] Implement matrix support for the `abs` intrinsic (PR #227131)
Kaitlin Peng via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 28 16:48:45 PDT 2026
================
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -fnative-int16-type -emit-llvm-only -disable-llvm-passes -verify
+
+float2x2 test_too_few_arg() {
+ return __builtin_elementwise_abs();
+ // expected-error at -1 {{too few arguments to function call, expected 1, have 0}}
+}
+
+float2x2 test_too_many_arg(float2x2 p0) {
+ return __builtin_elementwise_abs(p0, p0);
+ // expected-error at -1 {{too many arguments to function call, expected 1, have 2}}
+}
+
+float2x2 test_bool_matrix(bool2x2 p0) {
+ return __builtin_elementwise_abs(p0);
+ // expected-error at -1 {{1st argument must be a scalar or vector of signed integer or floating-point types (was 'bool2x2' (aka 'matrix<bool, 2, 2>'))}}
+}
+
+// The raw builtin rejects unsigned matrices.
+float2x2 test_unsigned_matrix(uint2x2 p0) {
+ return __builtin_elementwise_abs(p0);
+ // expected-error at -1 {{1st argument must be a scalar or vector of signed integer or floating-point types (was 'uint2x2' (aka 'matrix<uint, 2, 2>'))}}
----------------
kmpeng wrote:
There's an issue tracking that diagnostic update: #189147
We shouldn't do it in this PR because changing it would affect a lot of unrelated tests
https://github.com/llvm/llvm-project/pull/227131
More information about the cfe-commits
mailing list