summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuiling Song <ruiling.song@intel.com>2015-01-29 10:36:40 +0800
committerZhigang Gong <zhigang.gong@intel.com>2015-01-29 13:05:52 +0800
commit709cd5d49eb3cc747a4dbb59d28082f00d3c389d (patch)
treef7d4b240c24653d1b4fc004552eee6cf9483e382
parent3c407838c11c52be6f2ccb237884073566ed8c90 (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>
-rw-r--r--backend/src/llvm/llvm_passes.cpp18
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 =