This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][GlobalISel] Transform (fsub (fneg (fmul, x, y)), z) -> (fma (fneg x), y, (fneg z))
ClosedPublic

Authored by matejam on Mar 5 2021, 7:47 AM.

Details

Summary

Instead of sub and mul instructions, use v_mad, v_mac or v_fma if fma
instructions are faster and are legal for the given architecture.
Combiner for a case that has one multiplication, which gets negated, and
from that the third argument is subtracted. This combiner will transform
that into two negations and one fma/fmad instruction.

Diff Detail

Event Timeline

matejam created this revision.Mar 5 2021, 7:47 AM
matejam requested review of this revision.Mar 5 2021, 7:47 AM
matejam updated this revision to Diff 329338.Mar 9 2021, 7:18 AM

Put back the accidentally deleted combiner from the list of combiners (load_or_combine).

matejam updated this revision to Diff 343375.May 6 2021, 5:48 AM

Minor changes in CombinerHelper.cpp and in the tests.

matejam updated this revision to Diff 346786.May 20 2021, 10:27 AM

Use mi_match for comparing instructions instead of comparing the opcodes.

matejam updated this revision to Diff 375874.Sep 29 2021, 7:08 AM

Use m_MInstr instead of m_Reg in matching patterns (mi_match).
Instead of getting MachineInstr's, get only the Register values (no need for MachineInstr in this case).
Formatting and refactoring.

matejam updated this revision to Diff 376208.Sep 30 2021, 7:10 AM

Use applyBuildFn instead of writing my own apply.

matejam updated this revision to Diff 376525.Oct 1 2021, 7:27 AM

Changes in tests.

This revision is now accepted and ready to land.Nov 17 2021, 9:59 AM
matejam updated this revision to Diff 390334.Nov 29 2021, 6:21 AM

Added missing comments and an FMA combiner group in table gen.

This revision was landed with ongoing or failed builds.Nov 29 2021, 7:28 AM
This revision was automatically updated to reflect the committed changes.