[PATCH] D111529: Specify Clang vector builtins.

Steve Canon via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 11 07:39:23 PDT 2021


scanon added inline comments.


================
Comment at: clang/docs/LanguageExtensions.rst:538
+ T __builtin_elementwise_rint(T x)      return the integral value nearest to x (according to the          floating point types
+                                        prevailing rounding mode) in floating-point format
+ T __builtin_elementwise_round(T x)     return the integral value nearest to x rounding half-way cases    floating point types
----------------
"Prevailing rounding mode" is not super-useful, other than as a spelling for round-to-nearest-ties-to-even (IEEE 754 default rounding). Outside of a `FENV_ACCESS ON` context, there's not even really a notion of "prevailing rounding mode" to appeal to. I assume the intent is for this to lower to e.g. x86 ROUND* with the dynamic rounding-mode immediate.

I would recommend adding `__builtin_elementwise_roundeven(T x)` instead, which would statically bind IEEE default rounding (following TS 18661-1 naming) without having to appeal to prevailing rounding mode, and can still lower to ROUND* on x86 outside of FENV_ACCESS ON contexts, which is the norm for vector code  (and FRINTN unconditionally on armv8). I think we can punt on rint/nearbyint for now, and add them in the future if there's a need.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529



More information about the cfe-commits mailing list