[Beignet] [PATCH v2 2/2] GBE: optimize GEP constant offset calculation.

Zhigang Gong zhigang.gong at linux.intel.com
Mon Dec 1 22:42:59 PST 2014


Please ignore these two incorrect version 2 patches.

On Tue, Dec 02, 2014 at 02:38:58PM +0800, Zhigang Gong wrote:
> If the type is array or vector, we do not need to iterate each element.
> We can compute it directly.
> 
> Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
> ---
>  backend/src/llvm/llvm_passes.cpp | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp
> index 24ad9d0..8708ea9 100644
> --- a/backend/src/llvm/llvm_passes.cpp
> +++ b/backend/src/llvm/llvm_passes.cpp
> @@ -275,7 +275,7 @@ namespace gbe
>      Value* currentAddrInst = 
>        new PtrToIntInst(parentPointer, IntegerType::get(GEPInst->getContext(), ptrSize), "", GEPInst);
>  
> -    uint32_t constantOffset = 0;
> +    int32_t constantOffset = 0;
>  
>      for(uint32_t op=1; op<GEPInst->getNumOperands(); ++op)
>      {
> @@ -286,9 +286,10 @@ namespace gbe
>          int32_t offset = 0;
>          TypeIndex = ConstOP->getZExtValue();
>          int32_t step = TypeIndex > 0 ? 1 : -1;
> -        if (op == 1) {
> +        if (op == 1 || CompTy->isVectorTy() || CompTy->isArrayTy()) {
>            if (TypeIndex != 0) {
> -            Type *elementType = (cast<PointerType>(parentPointer->getType()))->getElementType();
> +            Type *elementType = (op == 1) ? (cast<PointerType>(parentPointer->getType()))->getElementType()
> +                                          : CompTy->getTypeAtIndex((uint32_t)0);
>              uint32_t elementSize = getTypeByteSize(unit, elementType);
>              uint32_t align = getAlignmentByte(unit, elementType);
>              elementSize += getPadding(elementSize, align);
> -- 
> 1.8.3.2
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list