LGTM. Thanks! Ruiling
> -----Original Message----- > From: Beignet [mailto:[email protected]] On Behalf Of > Pan Xiuli > Sent: Thursday, December 24, 2015 5:19 PM > To: [email protected] > Cc: Pan, Xiuli <[email protected]> > Subject: [Beignet] [PATCH V2] Backend: Refine new instruction with > IRBuilder create > > 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. > > V2: Change all alloca inst to the entry of the function. > Signed-off-by: Pan Xiuli <[email protected]> > --- > backend/src/llvm/llvm_scalarize.cpp | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > > diff --git a/backend/src/llvm/llvm_scalarize.cpp > b/backend/src/llvm/llvm_scalarize.cpp > index b48ff81..899a696 100644 > --- a/backend/src/llvm/llvm_scalarize.cpp > +++ b/backend/src/llvm/llvm_scalarize.cpp > @@ -732,25 +732,32 @@ 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()); > + BasicBlock &entry = > extr->getParent()->getParent()->getEntryBlock(); > + BasicBlock::iterator bbIter = entry.begin(); > + while (isa<AllocaInst>(bbIter)) ++bbIter; > + > + IRBuilder<> allocBuilder(&entry); > + allocBuilder.SetInsertPoint(bbIter); > + > + Alloc = allocBuilder.CreateAlloca(fooTy, nullptr, ""); > 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 > > _______________________________________________ > Beignet mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/beignet _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
