[llvm-commits] [llvm] r85692 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Owen Anderson resistor at mac.com
Sat Oct 31 23:35:50 PDT 2009


Chris,

On Oct 31, 2009, at 3:11 PM, Chris Lattner wrote:

> Author: lattner
> Date: Sat Oct 31 17:11:15 2009
> New Revision: 85692
>
> URL: http://llvm.org/viewvc/llvm-project?rev=85692&view=rev
> Log:
> Make sure PRE doesn't split crit edges from indirectbr.
>
> Modified:
>    llvm/trunk/lib/Transforms/Scalar/GVN.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=85692&r1=85691&r2=85692&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Sat Oct 31 17:11:15 2009
> @@ -1810,7 +1810,7 @@
>
> /// performPRE - Perform a purely local form of PRE that looks for  
> diamond
> /// control flow patterns and attempts to perform simple PRE at the  
> join point.
> -bool GVN::performPRE(Function& F) {
> +bool GVN::performPRE(Function &F) {
>   bool Changed = false;
>   SmallVector<std::pair<TerminatorInst*, unsigned>, 4> toSplit;
>   DenseMap<BasicBlock*, Value*> predMap;
> @@ -1875,6 +1875,10 @@
>       // we would need to insert instructions in more than one pred.
>       if (NumWithout != 1 || NumWith == 0)
>         continue;
> +
> +      // Don't do PRE across indirect branch.
> +      if (isa<IndirectBrInst>(PREPred->getTerminator()))
> +        continue;
>
>       // We can't do PRE safely on a critical edge, so instead we  
> schedule
>       // the edge to be split and perform the PRE the next time we  
> iterate
>

This isn't correct.  PREPred is the block in which the expression is  
already computed, so it never needs to split that edge.  What you need  
to check is that none of the other predecessors is via an indirect  
branch, as PRE would possibly need to split those edges to insert  
instructions.

--Owen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20091031/50a2a65c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20091031/50a2a65c/attachment.bin>


More information about the llvm-commits mailing list