[PATCH] D113817: [X86] Promote f16 STRICT_FROUND to f32 and call libc.

Phoebe Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 12 19:39:05 PST 2021


pengfei added inline comments.


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:22441-22444
 /// ISD::FROUND is defined to round to nearest with ties rounding away from 0.
 /// This mode isn't supported in hardware on X86. But as long as we aren't
 /// compiling with trapping math, we can emulate this with
 /// floor(X + copysign(nextafter(0.5, 0.0), X)).
----------------
craig.topper wrote:
> pengfei wrote:
> > craig.topper wrote:
> > > pengfei wrote:
> > > > What't the concern we can't emulate for `STRICT_FROUND`. I wonder if we have the same problem when promoting.
> > > I believe we can't emulate STRICT_FROUND the way we emulate FROUND because adding 0.4999999999 to a value that has no fractional bits will generate a spurious inexact exception when it gets truncated.
> > > 
> > > If the libcall is ok for f32 it should be ok for f16.
> > I see, thanks. But we may raise one more inexact exception when truncating back from f32, e.g. 2048.5
> > Not sure if it matters given we don't emulate the exception well in library too.
> I don't follow. The f32 libcall should always give back a number with no fractional bits.
Yes, but 2049 cannot be represented in FP16. The nearest one is 2050.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113817



More information about the llvm-commits mailing list