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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 26 05:21:26 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8754
+def err_elementwise_math_invalid_arg_type_2: Error <
+  "argument must have a %0 type, but was %1">;
+
----------------
I feel like we must already have a diagnostic that covers this case...


================
Comment at: clang/lib/Sema/SemaChecking.cpp:16547
+  Expr *A = TheCall->getArg(0);
+  QualType TyA = A->getType();
+
----------------
Should this type undergo the usual promotions?


================
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}}
+
----------------
fhahn wrote:
> 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
I was wondering about this myself, but also don't have strong opinions.


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