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 <[email protected]> --- 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 [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
