This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] Add basic optimizations for FREEZE in SelDag
ClosedPublic

Authored by aqjune on Mar 24 2020, 8:01 AM.

Details

Summary

This patch is the first effort to adding basic optimizations for FREEZE in SelDag.

Diff Detail

Event Timeline

aqjune created this revision.Mar 24 2020, 8:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2020, 8:01 AM
aqjune updated this revision to Diff 252328.Mar 24 2020, 8:03 AM

Minor fix

This patch should include test improvement diffs after D29014?

aqjune updated this revision to Diff 252350.Mar 24 2020, 9:25 AM

Update changes to fastisel & legalize tests

Tests?

Would having the changes to the two test files be sufficient?

lebedev.ri added inline comments.Mar 24 2020, 9:56 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
11593

Why are we creating a new freeze x when we already have freeze x in the form of N0?
(if it's due to the freeze semantics, please explain that in the code comment)

aqjune updated this revision to Diff 252358.Mar 24 2020, 10:00 AM

Don't create a redundant instruction

aqjune marked 2 inline comments as done.Mar 24 2020, 10:01 AM
aqjune added inline comments.
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
11593

You're right, it is fine to return N0. It was there because I was watching implementation of visitBITCAST.

aqjune marked an inline comment as done.Mar 24 2020, 10:04 AM

BTW, I tried to write a unit test that checks the freeze(freeze) -> freeze folding, but simply making llc print assembly wasn't enough to distinguish its effect. Is there a commandline option that prints SelDag just after dagcombiner?

BTW, I tried to write a unit test that checks the freeze(freeze) -> freeze folding, but simply making llc print assembly wasn't enough to distinguish its effect. Is there a commandline option that prints SelDag just after dagcombiner?

You could try something like "-stop-before=finalize-isel" and then check the MIR for an extra COPY instruction.
See llvm/test/CodeGen/X86/sqrt-fastmath-mir.ll for an example of that type of regression test.

aqjune updated this revision to Diff 252378.Mar 24 2020, 11:25 AM

Add freeze-combine.ll

aqjune marked an inline comment as done.Mar 24 2020, 11:26 AM

Thank you, I added a test.

llvm/test/CodeGen/X86/freeze-combine.ll
18 ↗(On Diff #252378)

This COPY seems to appear regardless of how many freezes are nested.

spatel accepted this revision.Mar 26 2020, 9:41 AM

LGTM - I'm not sure if we should also do these folds in SelectionDAGBuilder / getNode(), but that can be another patch if needed.

This revision is now accepted and ready to land.Mar 26 2020, 9:41 AM
This revision was automatically updated to reflect the committed changes.