Page MenuHomePhabricator

[DAGCombine] Do several rounds of combine for nodes using SimplifyDemandedBits.
Needs ReviewPublic

Authored by deadalnix on Mon, Jan 28, 7:08 PM.

Details

Summary

SimplifyDemandedBits can explore severallevels of the DAG docompute its result. This means that a transformation in the DAG that isn't immediately related to a node might affect it.

We therefore add these nodes to the DeepPatternNodes set so that they can be processed again in case the DAG is modfied.

In the future, other node may be added to the set as need arises.

This is a variation on D33587 that should be more lightweight as it focuses the extra work on node that are actually likely to benefit from it rather than the whole DAG.

Diff Detail

Event Timeline

deadalnix created this revision.Mon, Jan 28, 7:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptMon, Feb 4, 6:19 PM
niravd added a comment.Tue, Feb 5, 7:59 AM

I've been looking at this closely and it's descending in a chain of cleanups, after which I'm hoping we can do this in a more complete way.

I'm currently working on fixing the issue with SelectionDAG where we will leave unused nodes all around until they are cleaned up later in the combine pass or the next pass entirely. During the transient various optimizations relying on single use are disabled. This is another part of why the DAGCombiner fails to run to exhaustion of peephole optimizations. I suspect but have not verified that this a lot of the reason why each iteration makes improvements. I hope to have this up for review in a day or two.

My concern about this approach is that the DeepPatternNodes happening at the end of the iteration (and the multiple iteration) is partially hiding this issue. It'd be much more satisfying if we were adding this directly to the worklist and being handled immediately.

We also need to go a deeper than what we traverse SimplifyDemandedBits. At least we must add the users as well. Adding a variant to do of this catches a bunch of additional cases.