This is an archive of the discontinued LLVM Phabricator instance.

[X86] Remove what appear to be unnecessary uses of DCI.CombineTo
ClosedPublic

Authored by craig.topper on Jul 19 2018, 2:52 PM.

Details

Summary

CombineTo is most useful when you need to replace multiple results, avoid the worklist management, or you need to something else after the combine, etc. Otherwise you should be able to just return the new node and let DAGCombiner go through its usual worklist code.

All of the places changed in this patch look to be standard cases where we should be able to use the more stand behavior of just returning the new node.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jul 19 2018, 2:52 PM

I think this might have been to avoid the high cost of calling combineX86ShufflesRecursively again - can you see any compile time diffs? Possibly from one of the vector-shuffle-*.ll test files?

I'm not sure how it would have avoid calling it again. The "AddTo" argument defaults to true to its going to do

ReplaceAllUses(N, Res);
AddToWorklist(N);
AddUsersToWorklist(N);

I ran vector-shuffle-combining.ll with and without the patch with debug output. I got a less visits of things after this patch. It looks like the normal worklist management aggressively removes N and recursively all of its children using DAGCombiner::recursivelyDeleteUnusedNodes. CombineTo on the other hand just puts all the children of N in the Worklist and assumes they'll be deleted if necessary when they get visited. So depending on what's in the worklist some nodes might get visited before the process has gotten a chance to propagate the deadness up the graph.

RKSimon accepted this revision.Jul 20 2018, 2:38 AM

Thanks for checking! LGTM

This revision is now accepted and ready to land.Jul 20 2018, 2:38 AM
This revision was automatically updated to reflect the committed changes.