There's a folding pattern in DAGCombine:
(fsub x, (fma y, z, (fmul u, v))) -> (fma (fneg y), z, (fma (fneg u), v, x))
However, since -0-0=-0; -0+0=+0, if yz=1, uv=-1, x=-0:
x-(yz+uv) = -0 -yz+(-uv+x) = +0
So this requires nsz.
Paths
| Differential D76419
[DAGCombiner] Add nsz constraint to aggressive fma folding ClosedPublic Authored by qiucf on Mar 19 2020, 2:13 AM.
Details
Summary There's a folding pattern in DAGCombine: (fsub x, (fma y, z, (fmul u, v))) -> (fma (fneg y), z, (fma (fneg u), v, x)) However, since -0-0=-0; -0+0=+0, if yz=1, uv=-1, x=-0: x-(yz+uv) = -0 -yz+(-uv+x) = +0 So this requires nsz.
Diff Detail
Event Timeline
Comment Actions LGTM
This revision is now accepted and ready to land.Mar 20 2020, 9:42 AM qiucf added inline comments.
Closed by commit rG763871053cc0: [DAGCombiner] Require nsz for aggressive fma fold (authored by qiucf). · Explain WhyMar 22 2020, 8:31 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 251565 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AMDGPU/fma-combine.ll
llvm/test/CodeGen/AMDGPU/mad-combine.ll
llvm/test/CodeGen/PowerPC/fma-assoc.ll
|
clang-format: please reformat the code