[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LICM.cpp

Chris Lattner clattner at apple.com
Sat Apr 21 23:56:21 PDT 2007


> Switch more uses of DominatorTree over to ETForest.

This change is also subtly non-trival. Specially, stuff like this:
>
> -      DominatorTree::Node *BlockInLoopNode = DT->getNode 
> (BlockInLoop);
> -      DominatorTree::Node *IDom            = DT->getNode(ExitBlock);
> +      BasicBlock *IDom = ExitBlock;
>
>        // Because the exit block is not in the loop, we know we  
> have to get _at
>        // least_ its immediate dominator.
>        do {
>          // Get next Immediate Dominator.
> -        IDom = IDom->getIDom();
> +        IDom = ET->getIDom(IDom);
>
>          // If we have got to the header of the loop, then the  
> instructions block
>          // did not dominate the exit node, so we can't hoist it.
> -        if (IDom->getBlock() == LoopHeader)
> +        if (IDom == LoopHeader)
>            return false;
>
> -      } while (IDom != BlockInLoopNode);
> +      } while (IDom != BlockInLoop);

One of the key reasons that domtree was faster to use than idom was  
that traversing from a BB node to its idom was a simple pointer  
dereference.  In the case of idom, walking up idoms required a map  
lookup for each access.

Before your change, this would walk up the idom with a series of  
pointer dereferences, now we have to do map lookups. I don't see any  
specific reason why the code couldn't continue to walk up the  
etforest idom pointers, is there one?

-Chris





More information about the llvm-commits mailing list