[Beignet] [PATCH] GBE: Fix a bug at constant GEP processing.

Zhigang Gong zhigang.gong at intel.com
Mon Jan 6 18:41:22 PST 2014


We need to initialize the offset to zero for each new operand.

Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
 backend/src/llvm/llvm_gen_backend.cpp |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index 18e6967..8130882 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -923,13 +923,13 @@ namespace gbe
       } else {
         uint32_t TypeIndex;
         uint32_t constantOffset = 0;
-        uint32_t offset = 0;
 
         // currently only GetElementPtr is handled
         GBE_ASSERT(ce->getOpcode() == Instruction::GetElementPtr);
         Value *pointer = ce->getOperand(0);
         CompositeType* CompTy = cast<CompositeType>(pointer->getType());
         for(uint32_t op=1; op<ce->getNumOperands(); ++op) {
+          uint32_t offset = 0;
           ConstantInt* ConstOP = dyn_cast<ConstantInt>(ce->getOperand(op));
           GBE_ASSERT(ConstOP);
           TypeIndex = ConstOP->getZExtValue();
-- 
1.7.9.5



More information about the Beignet mailing list