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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 26 11:49:58 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:16547
+  Expr *A = TheCall->getArg(0);
+  QualType TyA = A->getType();
+
----------------
fhahn wrote:
> aaron.ballman wrote:
> > Should this type undergo the usual promotions?
> I'm not sure, but given that we only have a single argument then wouldn't it be sufficient to avoid promotion? I don't think promotion to wider types would impact the results of the provided builtins.
You set the type of the call to be the type of the argument, which means passing in a `const int` will result in a `const int` that's observable and probably unexpected. e.g. this will fail,
```
const int a = -12;
static_assert(!std::is_const_v<decltype(__builtin_elementwise_abs(a))>);
```
(This can come up with overload resolution or in template specializations.)


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