[Beignet] [PATCH] GBE: Only add non-zero offset in gep lowering pass.

Zhigang Gong zhigang.gong at linux.intel.com
Wed Jan 28 20:45:53 PST 2015


LGTM, will push latter, thanks.

On Thu, Jan 29, 2015 at 10:36:40AM +0800, Ruiling Song wrote:
> Signed-off-by: Ruiling Song <ruiling.song at intel.com>
> ---
>  backend/src/llvm/llvm_passes.cpp |   18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp
> index d315d53..5c0a2e0 100644
> --- a/backend/src/llvm/llvm_passes.cpp
> +++ b/backend/src/llvm/llvm_passes.cpp
> @@ -355,14 +355,16 @@ namespace gbe
>        CompTy = dyn_cast<CompositeType>(CompTy->getTypeAtIndex(TypeIndex));
>      }
>  
> -    //insert addition of new offset before GEPInst
> -    Constant* newConstOffset = 
> -      ConstantInt::get(IntegerType::get(GEPInst->getContext(), 
> -            ptrSize),
> -          constantOffset);
> -    currentAddrInst = 
> -      BinaryOperator::Create(Instruction::Add, currentAddrInst, 
> -          newConstOffset, "", GEPInst);
> +    //insert addition of new offset before GEPInst when it is not zero
> +    if (constantOffset != 0) {
> +      Constant* newConstOffset =
> +        ConstantInt::get(IntegerType::get(GEPInst->getContext(),
> +              ptrSize),
> +            constantOffset);
> +      currentAddrInst =
> +        BinaryOperator::Create(Instruction::Add, currentAddrInst,
> +            newConstOffset, "", GEPInst);
> +    }
>  
>      //convert offset to ptr type (nop)
>      IntToPtrInst* intToPtrInst = 
> -- 
> 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