[PATCH] D111986: [Clang] Add elementwise abs builtin.

Florian Hahn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 20 07:34:38 PDT 2021


fhahn marked 2 inline comments as done.
fhahn added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:16667
+
+  if (!TyA->getAs<VectorType>() && !ConstantMatrixType::isValidElementType(TyA))
+    return Diag(A->getBeginLoc(), diag::err_elementwise_math_invalid_arg_type)
----------------
scanon wrote:
> Given that I expect this particular test to occur fairly frequently, maybe worth abstracting into some sort of get-elementwise-type operation.
moved out to a helper in the previous patch in the series, D111985


================
Comment at: clang/test/Sema/builtins-elementwise-math.c:25
+  u = __builtin_elementwise_abs(u);
+  // expected-error at -1 {{argument must have a signed integer or floating point type, but was an unsigned integer type}}
+
----------------
scanon wrote:
> For the purposes of C++ templates it might be nice to allow `abs` on unsigned (as the identity function). I don't have strong feelings though, and a library wrapping the builtins can do this themselves.
yeah that would be an option. I don't have any strong feelings either


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111986/new/

https://reviews.llvm.org/D111986



More information about the cfe-commits mailing list