summaryrefslogtreecommitdiff
path: root/backend
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-03-10 15:51:07 +0800
commitee89a55555cc02f192172c950ef5605d651356e4 (patch)
tree6db64144d449d2af2c82c90216aa74daa52922f8 /backend
parent49eb83dbe20fbcec105d662134553efe7ba8f979 (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.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 7187caa6..1b403898 100644
--- a/backend/src/llvm/llvm_passes.cpp
+++ b/backend/src/llvm/llvm_passes.cpp
@@ -358,14 +358,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 =