[Beignet] [PATCH] GBE: Only add non-zero offset in gep lowering pass.
Ruiling Song
ruiling.song at intel.com
Wed Jan 28 18:36:40 PST 2015
Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
backend/src/llvm/llvm_passes.cpp | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp
index d315d53..5c0a2e0 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 =
--
1.7.10.4
More information about the Beignet
mailing list