llvm / llvm/llvm-project

[AMDGPU] To drop the FMA-fusion discount from the fmul cost?

Open
#211,092 5 comments 0 reactions 1 assignee Claimed by @MrSidims View on GitHub
backend:AMDGPU
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

See: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp#L585

getArithmeticInstrCost prices an FMUL whose only user is a contractable FADD or FSUB as free, assuming it will fuse into an FMA and the fadd will be charged for the whole pair. This made the cost depend on the context instruction as a hidden side effect as a per-instruction query returned the fused zero cost while a per-type query returned the standalone cost, and a caller holding the instruction had no way to ask for the standalone cost even when it was about to break the fusion.

Should we drop the discount so the fmul is always priced as a standalone operation? Fusion seem to be better modelled where it is actually formed, via the fmuladd intrinsic cost.

See discussion under this [comment](https://github.com/llvm/llvm-project/pull/210399#discussion_r3605547227).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.