This is an archive of the discontinued LLVM Phabricator instance.

StructurizeCFG: simplify phi nodes when possible
ClosedPublic

Authored by sameerds on Mar 2 2020, 10:54 PM.

Details

Summary

After structurization, some phi nodes can have a single incoming edge
and can be simplified away. This change runs a simplify query on all
phis that are either modified or added by the structurizer. This also
moves some phis closer to their use as a side benefit.

Diff Detail

Event Timeline

sameerds created this revision.Mar 2 2020, 10:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2020, 10:54 PM
arsenm added inline comments.Mar 3 2020, 11:27 AM
llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
662

continue on separate line

arsenm added inline comments.Mar 3 2020, 11:28 AM
llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
660

I think auto hurts readability here

sameerds added inline comments.Mar 3 2020, 6:59 PM
llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
660

Why is that? The next line immediately makes it clear that we are only instead if the "whatever I" is a PHINode. Also in general, how is this any different from say "for (auto BB : *F) { ... }" or "for (auto II : *BB) { ... }"?

sameerds updated this revision to Diff 248085.Mar 3 2020, 7:10 PM

address review comments

arsenm added inline comments.Mar 4 2020, 8:44 AM
llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
660

It's not, since it needs to be casted, and it's not even a normal Value, it's a WeakVH

sameerds updated this revision to Diff 248382.Mar 4 2020, 7:40 PM

addressed review comments

arsenm accepted this revision.Mar 4 2020, 8:31 PM
This revision is now accepted and ready to land.Mar 4 2020, 8:31 PM
This revision was automatically updated to reflect the committed changes.