diff options
author | Ruiling Song <ruiling.song@intel.com> | 2015-01-29 10:36:40 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-01-29 13:05:52 +0800 |
commit | 709cd5d49eb3cc747a4dbb59d28082f00d3c389d (patch) | |
tree | f7d4b240c24653d1b4fc004552eee6cf9483e382 /backend | |
parent | 3c407838c11c52be6f2ccb237884073566ed8c90 (diff) |
GBE: Only add non-zero offset in gep lowering pass.
Signed-off-by: Ruiling Song <ruiling.song@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'backend')
-rw-r--r-- | backend/src/llvm/llvm_passes.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp index d315d532..5c0a2e01 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 = |