[PATCH] D134859: [clang][Interp] Implement basic support for floating point values

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 9 01:24:36 PST 2022


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/Opcodes.td:502
+  let Types = [AluTypeClass];
+  let Args = [ArgFltSemantics];
+  let HasGroup = 1;
----------------
jcranmer-intel wrote:
> tbaeder wrote:
> > sepavloff wrote:
> > > tbaeder wrote:
> > > > jcranmer-intel wrote:
> > > > > Integer-to-floating point conversion is dependent on rounding mode--consider `(float)UINT_MAX`.
> > > > This test succeeds here, whether I use `-frounding-math` or not:
> > > > 
> > > > ```
> > > > constexpr float f = (float)4294967295;
> > > > static_assert(f == (float)4.2949673E+9);
> > > > ```
> > > > How can I test this behavior?
> > > You can use `#pragma STDC FENV_ROUND`. See `clang/test/AST/const-fpfeatures.c` as an example.
> > Why does it work here to compare both `f` and `f2` to the same value? https://godbolt.org/z/zdsf1sK7r
> `FENV_ROUND` is a new feature of C2x, so it doesn't look like it's properly handled in gcc or clang yet. (It's for sure not handled in clang--the code to convert a floating-point literal into an `APFloat` hardcodes default rounding mode in its call.)
> 
> Dynamic rounding mode shows you the difference: https://godbolt.org/z/856xM8KTh
So I can't test this at all because it first needs work in clang to do the float->APFloat conversion correctly?


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

https://reviews.llvm.org/D134859



More information about the cfe-commits mailing list