[PATCH] [SROA] Simplify PHI nodes before promoting the alloca
Mark Heffernan
meheff at google.com
Thu Jul 24 13:06:14 PDT 2014
Just a couple suggestions which might simplify the code.
================
Comment at: lib/Transforms/Scalar/SROA.cpp:3106
@@ +3105,3 @@
+ SmallPtrSetImpl<PHINode *> &OriginatesFromOther,
+ Value *Source) {
+ if (Visited.count(PN))
----------------
Couple bike-shed suggestions:
Maybe name the function PHINodeEquivalentToSource?
You could also replace both ptr sets with a map<PHINode *, bool> where membership indicates it's been visited and the value indicates equivalence.
================
Comment at: lib/Transforms/Scalar/SROA.cpp:3141
@@ +3140,3 @@
+ if (!PHINodeOriginatesFromOther(PN, Visited, OriginatesFromOther, NewAI))
+ ToDelete.insert(PN);
+ }
----------------
If you use a map<PHINode *, bool> for equivalence as mentioned above, you can cleanly do away with ToDelete. Just iterate through the map and replace the nodes with a true value. I, think, necessarily those will all be in PHIUsers.
http://reviews.llvm.org/D4659
More information about the llvm-commits
mailing list