[Beignet] [PATCH] GBE: We need use exiting block here.

Zhigang Gong zhigang.gong at linux.intel.com
Wed Feb 11 00:15:17 PST 2015


What the assertion does it hit with LLVM 3.6?

The original purpose to use latch block is:

  // Find "latch trip count". UnrollLoop assumes that control cannot exit
  // via the loop latch on any iteration prior to TripCount. The loop may exit
  // early via an earlier branch.

So if you use an exiting block here, you change the original logic, and
as you may know, one loop may have many exiting block, and some exiting block
may exit very early, so you may get a wrong currTripCount for the current loop
if you change to use an exiting block here.

On Wed, Feb 11, 2015 at 04:38:33PM +0800, Ruiling Song wrote:
> According to the API explanation, we should use exiting block instead of
> latch block. llvm 3.6 place an assert on this.
> 
> Signed-off-by: Ruiling Song <ruiling.song at intel.com>
> ---
>  backend/src/llvm/llvm_unroll.cpp |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/backend/src/llvm/llvm_unroll.cpp b/backend/src/llvm/llvm_unroll.cpp
> index f0ad4b4..38bfa3e 100644
> --- a/backend/src/llvm/llvm_unroll.cpp
> +++ b/backend/src/llvm/llvm_unroll.cpp
> @@ -177,19 +177,19 @@ namespace gbe {
>        bool handleParentLoops(Loop *L, LPPassManager &LPM) {
>          Loop *currL = L;
>          ScalarEvolution *SE = &getAnalysis<ScalarEvolution>();
> -        BasicBlock *latchBlock = currL->getLoopLatch();
> +        BasicBlock *ExitBlock = currL->getExitingBlock();
>          unsigned currTripCount = 0;
>          bool shouldUnroll = true;
> -        if (latchBlock)
> -          currTripCount = SE->getSmallConstantTripCount(L, latchBlock);
> +        if (ExitBlock)
> +          currTripCount = SE->getSmallConstantTripCount(L, ExitBlock);
>  
>          while(currL) {
>            Loop *parentL = currL->getParentLoop();
>            unsigned parentTripCount = 0;
>            if (parentL) {
> -            BasicBlock *parentLatchBlock = parentL->getLoopLatch();
> -            if (parentLatchBlock)
> -              parentTripCount = SE->getSmallConstantTripCount(parentL, parentLatchBlock);
> +            BasicBlock *parentExitBlock = parentL->getExitingBlock();
> +            if (parentExitBlock)
> +              parentTripCount = SE->getSmallConstantTripCount(parentL, parentExitBlock);
>            }
>            if ((parentTripCount != 0 && currTripCount / parentTripCount > 16) ||
>                (currTripCount > 32)) {
> -- 
> 1.7.10.4
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list