[PATCH] D70247: [JumpThreading] Thread jumps through two basic blocks

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 17:02:59 PST 2019


wmi added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/JumpThreading.cpp:1611-1612
+    // predecessors to increase jump threading opportunities.
+    if (MaybeCloneThreadableBasicBlock(BB, Cond))
+      return true;
     return false;
----------------
MaybeCloneThreadableBasicBlock may clone the predecessor of BB, return true and leaves the real threading job to the next call of ProcessBlock(BB). Is it possible that predecessor of BB is cloned but somehow threading doesn't happen in the next call of ProcessBlock(BB), and the clone is wasted? I know there are many checks in MaybeCloneThreadableBasicBlock to ensure most cases it won't happen, but maybe it is helpful to add some assertion to catch unexpected case?

For example, because ProcessBlock(BB) is called in a loop, we can save the information about whether any clone has happend in the loop, and any threading has happened, and add an assertion after the loop to check if clone has happened, threading must happen as well.  


================
Comment at: llvm/lib/Transforms/Scalar/JumpThreading.cpp:2122-2125
+  unsigned ZeroCount = 0;
+  unsigned OneCount = 0;
+  BasicBlock *ZeroPred = nullptr;
+  BasicBlock *OnePred = nullptr;
----------------
Why we care Cst is one or zero? Can we use CstCount instead? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70247/new/

https://reviews.llvm.org/D70247





More information about the llvm-commits mailing list