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

Zhigang Gong zhigang.gong at linux.intel.com
Wed Feb 11 22:47:54 PST 2015


LGTM, pushed, thanks.

On Thu, Feb 12, 2015 at 03:02:58PM +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.
> 
> v2:
>   Use latch block if it is the exiting block, else use exiting block.
> 
> Signed-off-by: Ruiling Song <ruiling.song at intel.com>
> ---
>  backend/src/llvm/llvm_unroll.cpp |   18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/backend/src/llvm/llvm_unroll.cpp b/backend/src/llvm/llvm_unroll.cpp
> index f0ad4b4..5d3fad8 100644
> --- a/backend/src/llvm/llvm_unroll.cpp
> +++ b/backend/src/llvm/llvm_unroll.cpp
> @@ -177,19 +177,25 @@ namespace gbe {
>        bool handleParentLoops(Loop *L, LPPassManager &LPM) {
>          Loop *currL = L;
>          ScalarEvolution *SE = &getAnalysis<ScalarEvolution>();
> -        BasicBlock *latchBlock = currL->getLoopLatch();
> +        BasicBlock *ExitBlock = currL->getLoopLatch();
> +        if (!ExitBlock || !L->isLoopExiting(ExitBlock))
> +          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->getLoopLatch();
> +            if (!parentExitBlock || !parentL->isLoopExiting(parentExitBlock))
> +              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