[all-commits] [llvm/llvm-project] 38570c: [NVPTX] Add native `tanh.approx` support for f16/f...

Varad Rahul Kamthe via All-commits all-commits at lists.llvm.org
Thu Jul 9 03:09:27 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 38570cae05860a5addf29f236faa273b99baffe3
      https://github.com/llvm/llvm-project/commit/38570cae05860a5addf29f236faa273b99baffe3
  Author: Varad Rahul Kamthe <133588066+varadk27 at users.noreply.github.com>
  Date:   2026-07-09 (Thu, 09 Jul 2026)

  Changed paths:
    M llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
    M llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
    M llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
    M llvm/test/CodeGen/NVPTX/tanhf.ll

  Log Message:
  -----------
  [NVPTX] Add native `tanh.approx` support for f16/f16x2/bf16/bf16x2 (#203257)

Adds NVPTX backend support for the native PTX `tanh.approx` instructions on half-precision and bfloat types:

- `tanh.approx.f16` and `tanh.approx.f16x2` (PTX 7.0+, sm_75+)
- `tanh.approx.bf16` and `tanh.approx.bf16x2` (PTX 7.8+, sm_90+)

Adds a `FTANHInst` TableGen class with the new patterns in NVPTXInstrInfo.td and splits `ISD::FTANH` out of the unconditional `f16/bf16 -> f32` promotion loop in NVPTXISelLowering.cpp, marking it Legal when the target supports it (scalars promote, vectors expand on older targets). Also guards `tanh.approx.f32` behind sm_75 and adds the
missing `AddPromotedToType` for bf16.

PTX Spec Reference:
https://docs.nvidia.com/cuda/parallel-thread-execution/#half-precision-floating-point-instructions-tanh

Signed-off-by: Varad Rahul Kamthe <vkamthe at nvidia.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list