[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 18 22:09:40 PDT 2023


sepavloff added inline comments.


================
Comment at: clang/docs/LanguageExtensions.rst:656
+  T __builtin_elementwise_nearbyint(T x)     round x to the nearest  integer value in floating point format,      floating point types
+                                             rounding halfway according to the current current rounding
+                                             direction. May not raise floating-point exceptions. This is
----------------
"halfway'" is superfluous here.


================
Comment at: clang/docs/LanguageExtensions.rst:657
+                                             rounding halfway according to the current current rounding
+                                             direction. May not raise floating-point exceptions. This is
+                                             treated the same as ``__builtin_elementwise_rint`` unless
----------------
`nearbyint` should not rise only `inexact` exception. Other exceptions, like `invalid` are allowed.


================
Comment at: clang/docs/LanguageExtensions.rst:662
+ T __builtin_elementwise_rint(T x)           round x to the nearest  integer value in floating point format,      floating point types
+                                             rounding halfway cases according to the current rounding
+                                             direction. May raise floating-point exceptions. This is treated
----------------
"halfway'" is superfluous here.


================
Comment at: clang/test/CodeGen/strictfp-elementwise-bulitins.cpp:2
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fexperimental-strict-floating-point -frounding-math -ffp-exception-behavior=strict -O2 -emit-llvm -o - %s | FileCheck %s
+
----------------
For X86 `-fexperimental-strict-floating-point` is not needed.


================
Comment at: clang/test/CodeGen/strictfp-elementwise-bulitins.cpp:13-14
+// CHECK-NEXT:    [[ADD:%.*]] = tail call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[TMP0]], <2 x float> [[TMP1]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR4:[0-9]+]]
+// CHECK-NEXT:    [[TMP2:%.*]] = bitcast <2 x float> [[ADD]] to double
+// CHECK-NEXT:    ret double [[TMP2]]
+//
----------------
Why vector type is bitcasted to scalar? The function must return <2 x float>, no?


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

https://reviews.llvm.org/D153233



More information about the cfe-commits mailing list