[PATCH] D152351: [clang] Add __builtin_isfpclass

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 12 22:26:21 PDT 2023


sepavloff marked 2 inline comments as done.
sepavloff added inline comments.


================
Comment at: clang/test/CodeGen/isfpclass.c:2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -O1 -emit-llvm %s -o - | FileCheck %s
+
+_Bool check_isfpclass_finite(float x) {
----------------
arsenm wrote:
> sepavloff wrote:
> > arsenm wrote:
> > >  Can you also add a half test, also vectors
> > Half is added. But vectors cannot, because in this case result is also a vector.
> Could copy what __builtin_elementwise does. Should that be in this builtin, or should there be a separate __builtin_elementwise_isfpclass?
Other math functions have separate elementwise functions. It looks natural to have separate elementwise function for this function as well.


================
Comment at: clang/test/Sema/builtins.c:384
+  int x1 = __builtin_isfpclass(x, 1024); // expected-error {{argument value 1024 is outside the valid range [0, 1023]}}
+  int x2 = __builtin_isfpclass(3, 3); // expected-error{{floating point classification requires argument of floating point type (passed in 'int')}}
+  int x3 = __builtin_isfpclass(x, 3, x); // expected-error{{too many arguments to function call, expected 2, have 3}}
----------------
arsenm wrote:
> For any other float argument, 3 would accept implicit conversion. Do we just not do that for these type inferring intrinsics?
As any other classification function, this one is evaluated with semantic type. The test `CodeGen/isfpclass.c` demonstrates that type promotion is absent for _Float16.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152351



More information about the cfe-commits mailing list