[Beignet] [PATCH] Backend: Refine new instruction with IRBuilder create
Pan Xiuli
xiuli.pan at intel.com
Thu Dec 24 00:24:30 PST 2015
New instruction changes with the llvm version but the IRbuilder
is more stables. So use IRBuilder create to make it can be built
with more llvm version.
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
backend/src/llvm/llvm_scalarize.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/backend/src/llvm/llvm_scalarize.cpp b/backend/src/llvm/llvm_scalarize.cpp
index b48ff81..0f84eea 100644
--- a/backend/src/llvm/llvm_scalarize.cpp
+++ b/backend/src/llvm/llvm_scalarize.cpp
@@ -732,25 +732,25 @@ namespace gbe {
Value* foo = extr->getOperand(0);
Type* fooTy = foo->getType();
- Instruction* Alloc;
+ Value* Alloc;
if(vectorAlloca.find(foo) == vectorAlloca.end())
{
- Alloc = new AllocaInst(fooTy,0,"",extr->getParent()->begin());
+ Alloc = new AllocaInst(fooTy, nullptr , "", extr->getParent()->begin());
for (int i = 0; i < GetComponentCount(foo); ++i)
{
Value* foo_i = getComponent(i, foo);
assert(foo_i && "There is unhandled vector component");
Value* idxs_i[] = {ConstantInt::get(intTy,0), ConstantInt::get(intTy,i)};
- Instruction* storePtr_i = GetElementPtrInst::Create(Alloc, idxs_i, "", extr);
- new StoreInst(foo_i, storePtr_i, extr);
+ Value* storePtr_i = builder->CreateGEP(Alloc, idxs_i);
+ builder->CreateStore(foo_i, storePtr_i);
}
vectorAlloca[foo] = Alloc;
}
- else Alloc = dyn_cast<Instruction>(vectorAlloca[foo]);
+ else Alloc = vectorAlloca[foo];
Value* Idxs[] = {ConstantInt::get(intTy,0), extr->getOperand(1)};
- Instruction* getPtr = GetElementPtrInst::Create(Alloc, Idxs, "", extr);
- Instruction* loadComp = new LoadInst(getPtr,"",extr);
+ Value* getPtr = builder->CreateGEP(Alloc, Idxs);
+ Value* loadComp = builder->CreateLoad(getPtr);
extr->replaceAllUsesWith(loadComp);
return true;
}
--
2.1.4
More information about the Beignet
mailing list