[PATCH] D37163: [LICM] sink through non-trivially replicable PHI

Jun Bum Lim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 7 10:23:03 PDT 2017


junbuml added inline comments.


================
Comment at: lib/Transforms/Scalar/LICM.cpp:911
+    UE = I.user_end();
+  }
 
----------------
dberlin wrote:
> Is there a reason not to just put all the users in a smallvector of WeakVH first?
> While it's true splitPred may invalidate the iterators, none of the answers to what this loop does can change (that i can see) as a result of that (nor will this loop do anything for any new values).
> 
After splitPredecessorsOfLoopExit(), user PHIs will be modified and could no longer be an user and also could be not in the exit block anymore.  We also need to get Use from user_iterator for the unreachability check for Phi's incoming block in this loop. Instead of holding the original users and iterating them over, I think restarting the iterators for valid users might be earlier to read. To avoid performing the same check for the same users, I cached visited users.
 
If you see the test16() in the test case, the same phi is used multiple times as an user. After splitPredecessorsOfLoopExit, the PHI will no longer be an user of the sinkable instruction, so we may not want to revisit this no-longer-user phi.



https://reviews.llvm.org/D37163





More information about the llvm-commits mailing list