<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
<br>
</span>The pattern we are matching does not match this example: please correct me if I'm wrong here.<br>
The only case we are handling is without the intermediate blocks 2 and 3 on your example:<br>
<br>
  BasicBlock *BB = Dom->getBlock();<br>
  // Only handle two branches for now: it is possible to extend the hoisting<br>
  // to switch statements.<br>
  BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator());<br>
  if (!BI || BI->getNumSuccessors() != 2)<br>
    return false;<br></blockquote><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
BB1 and BB2 are the direct successors of BB: there is no other block in between. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We only hoist expressions from BB1 and BB2 into BB.<br>
<span class=""><br></span></blockquote><div><br></div><div>Yes, i misread this part.  </div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> 3. This seems like a really expensive way of doing this :)<br>
<br>
><br>
<br>
>   This is pretty badly N^2.<br>
<br>
><br>
<br>
>   Can i suggest a different method, closely based on what we do in GCC for speed reasons<br>
<br>
<br>
</span>We will implement your suggestion: Aditya has also remarked that we could be more efficient on compile time by using the internal structures of the VN table, though I agree with you that we will need some more changes.<br></blockquote><div><br></div><div>(FWIW: New GVN already has such a mapping/structure. For each value, it can tell you all the member expressions of that value) </div><div><br></div></div></div></div>