This is an archive of the discontinued LLVM Phabricator instance.

[PhiValues] Remove redundant map searches
ClosedPublic

Authored by ekatz on Oct 23 2019, 5:27 AM.

Details

Summary

Remove redundant map searches.
For example, every call to "operator[]" is actually translated to a "find" call, and 2 consecutive calls to the operator, without changing the map in-between, is just redundant, and inefficient.

Diff Detail

Event Timeline

ekatz created this revision.Oct 23 2019, 5:27 AM

Reducing the repeated lookups in DepthMap seems reasonable, but the changes to the loop where ReachableMap is updated make it quite a bit more difficult to understand (as the task of updating ReachableMap is smushed together with the task of updating NonPhiReachableMap). Could you do just the first part? Or are there cases where this majorly speeds things up?

llvm/lib/Analysis/PhiValues.cpp
88

It looks like this line is deleted and there's no equivalent to it in the patch.

ekatz marked an inline comment as done.Nov 17 2019, 3:43 AM
ekatz added inline comments.
llvm/lib/Analysis/PhiValues.cpp
88

It is done at line 124 of the patch.

ekatz updated this revision to Diff 229715.Nov 17 2019, 3:45 AM

Separated the update of NonPhiReachableMap from ReachableMap as requested.

This revision is now accepted and ready to land.Nov 21 2019, 4:12 AM
ekatz retitled this revision from [PhiValues] Remove redundant searches in DenseMap to [PhiValues] Remove redundant map searches.Nov 23 2019, 12:25 AM
ekatz edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.