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

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 15 10:23:43 PST 2019


wmi added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/JumpThreading.cpp:2122-2125
+  unsigned ZeroCount = 0;
+  unsigned OneCount = 0;
+  BasicBlock *ZeroPred = nullptr;
+  BasicBlock *OnePred = nullptr;
----------------
kazu wrote:
> wmi wrote:
> > Why we care Cst is one or zero? Can we use CstCount instead? 
> The reason why I care about specific constants is that I would like to set up the CFG so that after calling MaybeCloneThreadableBasicBlock, taking the edge from NewBB to BB will necessarily imply which successor edge we take out of BB.
> 
> By CstCount, I assume you are proposing to count the number of incoming edges into PredBB with known successor edges out of BB.  If we do so, we could end up with CstCount == 2, where one incoming edge into PredBB takes the "then" edge out of BB, and the other takes the "else" edge.  That doesn't tell us which edge into PredBB we should redirect to NewBB.
> 
> Note that for simplicity, I would like to redirect exactly one incoming edge into PredBB to NewBB when no other incoming edge into PredBB is known to always take the same successor edge out of BB, which is why I care about ZeroCount == 1 or OneCount == 1.
> Note that for simplicity, I would like to redirect exactly one incoming edge into PredBB to NewBB when no other incoming edge into PredBB is known to always take the same successor edge out of BB, which is why I care about ZeroCount == 1 or OneCount == 1.

I see, thanks. It is good to put the above in the comment and add a TODO there, if you plan to handle the case with multiple PredBBs threading into the same SuccBB later on.


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