On 1/8/22 13:21, Roger Sayle wrote:

This patch adds more support for _Float16 (HFmode) to the nvptx backend.
Currently negation, absolute value and floating point comparisons are
implemented by promoting to float (SFmode).  This patch adds suitable
define_insns to nvptx.md, most conditional on TARGET_SM53 (-misa=sm_53).
This patch also adds support for HFmode fused multiply-add.

One subtlety is that neghf2 and abshf2 are implemented by (HImode)
bit manipulation operations to update the sign bit.  The NVidia PTX
ISA documentation for neg.f16 and abs.f16 contains the caution
"Future implementations may comply with the IEEE 754 standard by preserving
the (NaN) payload and modifying only the sign bit".  Given the availability
of suitable replacements, I thought it best to provide IEEE 754 compliant
implementations.  If anyone observes a performance penalty from this
choice I'm happy to provide a -ffast-math variant (or revisit this
decision).

This patch has been tested on nvptx-none hosted on x86_64-pc-linux-gnu
(including newlib) with a make and make -k check with no new failures.
Ok for mainline?


LGTM, applied.

Thanks,
- Tom


2022-01-08  Roger Sayle  <ro...@nextmovesoftware.com>

gcc/ChangeLog
        * config/nvptx/nvptx.md (*cmpf): New define_insn.
        (cstorehf4): New define_expand.
        (fmahf4): New define_insn.
        (neghf2): New define_insn.
        (abshf2): New define_insn.

gcc/testsuite/ChangeLog
        * gcc.target/nvptx/float16-3.c: New test case for neghf2.
        * gcc.target/nvptx/float16-4.c: New test case for abshf2.
        * gcc.target/nvptx/float16-5.c: New test case for fmahf4.
        * gcc.target/nvptx/float16-6.c: New test case.


Thanks in advance,
Roger
--

Reply via email to