This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Check term use before applying aggressive FSUB optimisation
ClosedPublic

Authored by critson on Dec 18 2019, 4:28 AM.

Details

Summary

Without this check unnecessary FMA instructions are generated when the FSUB RHS term is reused.
This also has the side-effect that the same value is computed to different levels of precision, which can create undesirable effects if the results are used together in subsequent computation.

Diff Detail

Event Timeline

critson created this revision.Dec 18 2019, 4:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 18 2019, 4:28 AM
critson edited the summary of this revision. (Show Details)Dec 18 2019, 6:07 PM
critson added reviewers: foad, tpr, dstuttard, spatel.
foad added a comment.Dec 19 2019, 1:13 AM

Looks like this case was missed in rL291642. Is it worth checking the other cases too, e.g. the next one at line 11896? Can you add your test to fadd-fma-fmul-combine.ll instead of creating a new test file?

Looks like this case was missed in rL291642. Is it worth checking the other cases too, e.g. the next one at line 11896? Can you add your test to fadd-fma-fmul-combine.ll instead of creating a new test file?

Thanks for pointing this out. I'll review the other cases and integrate the tests into the same file. It looks like the test I created is just a mirror of the previous test with LHS and RHS swapped.

critson updated this revision to Diff 234826.Dec 19 2019, 9:25 PM

Unify with existing tests and apply usage check to further similar patterns.

arsenm added inline comments.Dec 21 2019, 1:37 AM
llvm/test/CodeGen/AMDGPU/fadd-fma-fmul-combine.ll
258

s/CHECK/GCN

arsenm accepted this revision.Dec 21 2019, 1:38 AM

LGTM with check prefix fix

This revision is now accepted and ready to land.Dec 21 2019, 1:38 AM
foad added inline comments.Dec 21 2019, 3:34 AM
llvm/test/CodeGen/AMDGPU/fadd-fma-fmul-combine.ll
258

s/GCN/GCN-LABEL/ :-)

This revision was automatically updated to reflect the committed changes.