[llvm-commits] [llvm] r112594 - /llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp

Chris Lattner clattner at apple.com
Tue Aug 31 10:11:19 PDT 2010


On Aug 31, 2010, at 12:55 AM, Owen Anderson wrote:

> Author: resistor
> Date: Tue Aug 31 02:55:56 2010
> New Revision: 112594
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=112594&view=rev
> Log:
> Don't perform an extra traversal of the function just to do cleanup.  We can safely simplify instructions after each block has been processed without worrying about iterator invalidation.

Should this only be done if(Changed)?  If not, you need to make sure to keep Changed up to date if simplify changes the block.

-Chris

> 
> Modified:
>    llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp?rev=112594&r1=112593&r2=112594&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp Tue Aug 31 02:55:56 2010
> @@ -102,7 +102,7 @@
> 
>   bool Changed = false;
> 
> -  for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
> +  for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) {
>     for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ) {
>       Instruction *II = BI++;
>       if (SelectInst *SI = dyn_cast<SelectInst>(II))
> @@ -110,10 +110,9 @@
>       else if (PHINode *P = dyn_cast<PHINode>(II))
>         Changed |= processPHI(P);
>     }
> -  
> -  if (Changed)
> -    for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
> -      SimplifyInstructionsInBlock(FI);
> +    
> +    SimplifyInstructionsInBlock(FI);
> +  }
> 
>   return Changed;
> }
> 
> 
> _______________________________________________
> 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