[PATCH] D51471: [SimplifyCFG] Reduce memory churn during common case for branch commoning [NFC]

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 30 00:58:22 PDT 2018


mkazantsev accepted this revision.
mkazantsev added a comment.
This revision is now accepted and ready to land.

Oh, I've misread what function that was. If both branches go to the same block then it should be fine.



================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2694
+    Instruction *CondInPred = nullptr;
+    if (PredCount == 1) {
+      for (auto BonusInstItr = BB->begin(); Cond != &*BonusInstItr;) {
----------------
mkazantsev wrote:
> What if the predecessor block has more than one successor? You'll end up moving loads and other dangerous instruction across conditional branches.
I've misread what method was that, my bad. :) This should be fine.
However I have no idea how iterators interact with `moveBefore`, it may be safier to use an auxiliary vector here for that.


https://reviews.llvm.org/D51471





More information about the llvm-commits mailing list