[llvm-commits] [llvm] r44905 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Chris Lattner clattner at apple.com
Tue Dec 11 20:31:45 PST 2007


On Dec 11, 2007, at 6:53 PM, Evan Cheng wrote:

> Author: evancheng
> Date: Tue Dec 11 20:53:41 2007
> New Revision: 44905
>
> URL: http://llvm.org/viewvc/llvm-project?rev=44905&view=rev
> Log:
> Don't muck with phi nodes; bug fixes.

Hey Evan, testcase please :)

-Chris

>
> Modified:
>    llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=44905&r1=44904&r2=44905&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Dec 11  
> 20:53:41 2007
> @@ -930,8 +930,8 @@
>     return false;
>
>   // Only safe to perform the optimization if the source is also  
> defined in
> -  // this block.
> -  if (DefBB != cast<Instruction>(Src)->getParent())
> +  // this block.
> +  if (!isa<Instruction>(Src) || DefBB != cast<Instruction>(Src)- 
> >getParent())
>     return false;
>
>   bool DefIsLiveOut = false;
> @@ -948,6 +948,15 @@
>   if (!DefIsLiveOut)
>     return false;
>
> +  // Make sure non of the uses are PHI nodes.
> +  for (Value::use_iterator UI = Src->use_begin(), E = Src->use_end();
> +       UI != E; ++UI) {
> +    Instruction *User = cast<Instruction>(*UI);
> +    if (User->getParent() == DefBB) continue;
> +    if (isa<PHINode>(User))
> +      return false;
> +  }
> +
>   // InsertedTruncs - Only insert one trunc in each block once.
>   DenseMap<BasicBlock*, Instruction*> InsertedTruncs;
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list