This is an archive of the discontinued LLVM Phabricator instance.

[GISel]: Allow Unused G_PHIs to be DCEd
ClosedPublic

Authored by aditya_nandakumar on Oct 15 2018, 4:14 PM.

Details

Summary

currently G_PHIs which are not used are still not cleaned up by DCE (as it's currently not considered safe to move). This patch changes that for G_PHI (not the PHI instruction).

Diff Detail

Repository
rL LLVM

Event Timeline

dsanders accepted this revision.Oct 16 2018, 8:46 AM

LGTM with a nit. Also we should consider whether we ought to be calling isSafeToMove() when we're not moving things.

lib/CodeGen/GlobalISel/Utils.cpp
140

As a side note, isSafeToMove() doesn't seem like the right check in any case since we're not planning to move it. We really want a mayHaveSideEffects() or isSafeToErase(). That said, the contents would be largely the same so it makes little difference aside from clearer labelling of the intent.

141

We should use isPhi() instead. It's just as valid to delete dead PHI's we have in the late stages of the pipeline as it is to delete dead G_PHI's in the early stages

This revision is now accepted and ready to land.Oct 16 2018, 8:46 AM

Submitted in r344811