This is an archive of the discontinued LLVM Phabricator instance.

Remove unnecessary IDom check
ClosedPublic

Authored by trentxintong on Nov 21 2016, 7:58 PM.

Details

Summary

This Idom check seems unnecessary. The immediate children of a node on the Dominator Tree should always be the IDom of its immediate children in this case.

Diff Detail

Repository
rL LLVM

Event Timeline

trentxintong retitled this revision from to Remove unnecessary IDom check.
trentxintong updated this object.
trentxintong added reviewers: hfinkel, majnemer.
trentxintong set the repository for this revision to rL LLVM.
trentxintong added a subscriber: llvm-commits.

Gentle ping ? I will close this patch if no one is interested in Sink.cpp anymore.

davide added a subscriber: davide.Mar 19 2017, 12:59 PM
davide added inline comments.
Sink.cpp
172 ↗(On Diff #78822)

Add a comment here to explain why you don't need to check.

Address davide's comment

dberlin added inline comments.
lib/Transforms/Scalar/Sink.cpp
174 ↗(On Diff #92295)

I wouldn't even bother with this assert.
Just remove it and commit.

Honestly, this whole code is silly.

If you want to take a whack at it, the proper (IMHO) way to do this is:

ncdblock = find nearestcommondominator(blocks that contain uses)

If ncdblock == Inst->getParent(), stop, can't sink.
Otherwise,
while (!AcceptableTarget(Inst, ncdblock) && ncdblock != Inst->getParent())
, NCDBlock = getIDom(NCDBlock);

This will sink as low as possible.
You can then remove the allusesdominatedbyblock check from IsAcceptableTarget. Any idom of the ncd must, by definition, still dominate the uses.
Note that when computing NearestCommonDominator(uses), phi uses have to be considered to live at the end of the incoming block they come from to get optimal results.

dberlin accepted this revision.Mar 19 2017, 3:57 PM
This revision is now accepted and ready to land.Mar 19 2017, 3:57 PM

(Though note, it's probably the case that few people care about Sink.cpp anymore)

trentxintong added inline comments.Mar 19 2017, 4:17 PM
lib/Transforms/Scalar/Sink.cpp
174 ↗(On Diff #92295)

Thats what I have in mind as well. However, this would work well for sinking SSA values, but not memory reading/writing instructions.

Sink.cpp has some simple abilities to sink loads and stores.

trentxintong added inline comments.Mar 19 2017, 4:35 PM
lib/Transforms/Scalar/Sink.cpp
174 ↗(On Diff #92295)

By SSA values I meant instructions without reading/writing to memory.

dberlin added inline comments.Mar 19 2017, 4:55 PM
lib/Transforms/Scalar/Sink.cpp
174 ↗(On Diff #92295)

If we cared, we'd just run MemorySSA, and for loads/stores, and then you have the SSA form you need to sink stores

Address comments.

Ok, I have not had the time to look at the MemorySSA work (I have plan to get to it in the near future). I will land this for now. This pass probably needs to be significantly changed (essentially rewritten) later if we need it.

This revision was automatically updated to reflect the committed changes.