[all-commits] [llvm/llvm-project] 8010f1: [AMDGPU] Fold fpround of fadd and fsub into v_mad/...

Dmitry Sidorov via All-commits all-commits at lists.llvm.org
Mon Sep 21 11:11:10 PDT 2026


  Branch: refs/heads/users/mrsidims/fix-amdgpu-mix-fadd-fsub-fold
  Home:   https://github.com/llvm/llvm-project
  Commit: 8010f198f03c15e1910cd1e5385a216f088938ce
      https://github.com/llvm/llvm-project/commit/8010f198f03c15e1910cd1e5385a216f088938ce
  Author: Dmitry Sidorov <Dmitry.Sidorov at amd.com>
  Date:   2026-09-21 (Mon, 21 Sep 2026)

  Changed paths:
    M llvm/lib/Target/AMDGPU/VOP3PInstructions.td
    M llvm/test/CodeGen/AMDGPU/GlobalISel/fdiv.f16.ll
    M llvm/test/CodeGen/AMDGPU/bf16.ll
    M llvm/test/CodeGen/AMDGPU/fdiv.f16.ll
    M llvm/test/CodeGen/AMDGPU/fold-int-pow2-with-fmul-or-fdiv.ll
    M llvm/test/CodeGen/AMDGPU/frem.ll
    M llvm/test/CodeGen/AMDGPU/mad-mix-hi-bf16.ll
    M llvm/test/CodeGen/AMDGPU/mad-mix-hi.ll
    M llvm/test/CodeGen/AMDGPU/mad-mix-lo-bf16.ll
    M llvm/test/CodeGen/AMDGPU/mad-mix-lo.ll

  Log Message:
  -----------
  [AMDGPU] Fold fpround of fadd and fsub into v_mad/fma_mixlo and mixhi

MadFmaMixFP32Pats turns (fadd x, y) into (fma x, 1.0, y) and (fsub x, y)
into (fma (-y), 1.0, x) so the mix instructions absorb the operation along
with the f16 or bf16 source modifiers. MadFmaMixFP16Pats and
MadFmaMixFP16Pats_t16 only did this for fmul, so a rounded result still
needed a separate convert for a rounding the mix instructions perform
themselves.

Unlike the f32 patterns these do not require an operand to be an fpextend
of an f16, since an fpround on the result always removes the convert. The
rewrite is exact because the mix instructions round the f32 result again
when they write the 16-bit destination, so it stays f32_to_f16(fma(x, 1.0,
y)).

Assisted-by: Claude Code Opus 5



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