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

Steve Canon via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 19 13:02:20 PDT 2021


scanon accepted this revision.
scanon added a comment.
This revision is now accepted and ready to land.

Two minor questions, but also LGTM as is.



================
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)
----------------
Given that I expect this particular test to occur fairly frequently, maybe worth abstracting into some sort of get-elementwise-type operation.


================
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}}
+
----------------
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.


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