Lines Matching refs:Ice
27 void run(Ice::Cfg *function);
30 void analyzeUses(Ice::Cfg *function);
36 void replace(Ice::Inst *instruction, Ice::Operand *newValue);
37 void deleteInstruction(Ice::Inst *instruction);
38 bool isDead(Ice::Inst *instruction);
40 static const Ice::InstIntrinsicCall *asLoadSubVector(const Ice::Inst *instruction);
41 static const Ice::InstIntrinsicCall *asStoreSubVector(const Ice::Inst *instruction);
42 static bool isLoad(const Ice::Inst &instruction);
43 static bool isStore(const Ice::Inst &instruction);
44 static Ice::Operand *storeAddress(const Ice::Inst *instruction);
45 static Ice::Operand *loadAddress(const Ice::Inst *instruction);
46 static Ice::Operand *storeData(const Ice::Inst *instruction);
47 static std::size_t storeSize(const Ice::Inst *instruction);
48 static bool loadTypeMatchesStore(const Ice::Inst *load, const Ice::Inst *store);
50 Ice::Cfg *function;
51 Ice::GlobalContext *context;
53 struct Uses : std::vector<Ice::Inst*>
56 void insert(Ice::Operand *value, Ice::Inst *instruction);
57 void erase(Ice::Inst *instruction);
59 std::vector<Ice::Inst*> loads;
60 std::vector<Ice::Inst*> stores;
65 LoadStoreInst(Ice::Inst* inst, bool isStore) in LoadStoreInst()
72 Ice::Inst* inst;
73 Ice::Operand *address;
77 Optimizer::Uses* getUses(Ice::Operand*);
78 void setUses(Ice::Operand*, Optimizer::Uses*);
79 bool hasUses(Ice::Operand*) const;
81 Ice::CfgNode* getNode(Ice::Inst*);
82 void setNode(Ice::Inst*, Ice::CfgNode*);
84 Ice::Inst* getDefinition(Ice::Variable*);
85 void setDefinition(Ice::Variable*, Ice::Inst*);
87 const std::vector<LoadStoreInst>& getLoadStoreInsts(Ice::CfgNode*);
88 void setLoadStoreInsts(Ice::CfgNode*, std::vector<LoadStoreInst>*);
89 bool hasLoadStoreInsts(Ice::CfgNode* node) const;
94 void Optimizer::run(Ice::Cfg *function) in run()
120 for(Ice::CfgNode *basicBlock : function->getNodes()) in eliminateDeadCode()
122 for(Ice::Inst &inst : Ice::reverse_range(basicBlock->getInsts())) in eliminateDeadCode()
142 Ice::CfgNode *entryBlock = function->getEntryNode(); in eliminateUnitializedLoads()
144 for(Ice::Inst &alloca : entryBlock->getInsts()) in eliminateUnitializedLoads()
151 if(!llvm::isa<Ice::InstAlloca>(alloca)) in eliminateUnitializedLoads()
156 Ice::Operand *address = alloca.getDest(); in eliminateUnitializedLoads()
172 for(Ice::Inst *load : addressUses.loads) in eliminateUnitializedLoads()
174 Ice::Variable *loadData = load->getDest(); in eliminateUnitializedLoads()
178 for(Ice::Inst *use : *getUses(loadData)) in eliminateUnitializedLoads()
180 for(Ice::SizeT i = 0; i < use->getSrcSize(); i++) in eliminateUnitializedLoads()
205 Ice::CfgNode *entryBlock = function->getEntryNode(); in eliminateLoadsFollowingSingleStore()
207 for(Ice::Inst &alloca : entryBlock->getInsts()) in eliminateLoadsFollowingSingleStore()
214 if(!llvm::isa<Ice::InstAlloca>(alloca)) in eliminateLoadsFollowingSingleStore()
219 Ice::Operand *address = alloca.getDest(); in eliminateLoadsFollowingSingleStore()
235 Ice::Inst *store = addressUses.stores[0]; in eliminateLoadsFollowingSingleStore()
236 Ice::Operand *storeValue = storeData(store); in eliminateLoadsFollowingSingleStore()
238 …for(Ice::Inst *load = &*++store->getIterator(), *next = nullptr; load != next; next = load, load =… in eliminateLoadsFollowingSingleStore()
314 Ice::CfgNode *entryBlock = function->getEntryNode(); in optimizeStoresInSingleBasicBlock()
318 for(Ice::Inst &alloca : entryBlock->getInsts()) in optimizeStoresInSingleBasicBlock()
325 if(!llvm::isa<Ice::InstAlloca>(alloca)) in optimizeStoresInSingleBasicBlock()
330 Ice::Operand *address = alloca.getDest(); in optimizeStoresInSingleBasicBlock()
344 Ice::CfgNode *singleBasicBlock = getNode(addressUses.stores[0]); in optimizeStoresInSingleBasicBlock()
348 Ice::Inst *store = addressUses.stores[i]; in optimizeStoresInSingleBasicBlock()
363 for(Ice::Inst &inst : singleBasicBlock->getInsts()) in optimizeStoresInSingleBasicBlock()
380 Ice::Inst *store = nullptr; in optimizeStoresInSingleBasicBlock()
381 Ice::Operand *storeValue = nullptr; in optimizeStoresInSingleBasicBlock()
386 Ice::Inst* inst = loadStoreInst.inst; in optimizeStoresInSingleBasicBlock()
430 void Optimizer::analyzeUses(Ice::Cfg *function) in analyzeUses()
432 for(Ice::CfgNode *basicBlock : function->getNodes()) in analyzeUses()
434 for(Ice::Inst &instruction : basicBlock->getInsts()) in analyzeUses()
447 for(Ice::SizeT i = 0; i < instruction.getSrcSize(); i++) in analyzeUses()
449 Ice::SizeT unique = 0; in analyzeUses()
460 Ice::Operand *src = instruction.getSrc(i); in analyzeUses()
468 void Optimizer::replace(Ice::Inst *instruction, Ice::Operand *newValue) in replace()
470 Ice::Variable *oldValue = instruction->getDest(); in replace()
479 for(Ice::Inst *use : *getUses(oldValue)) in replace()
483 for(Ice::SizeT i = 0; i < use->getSrcSize(); i++) in replace()
500 void Optimizer::deleteInstruction(Ice::Inst *instruction) in deleteInstruction()
509 for(Ice::SizeT i = 0; i < instruction->getSrcSize(); i++) in deleteInstruction()
511 Ice::Operand *src = instruction->getSrc(i); in deleteInstruction()
523 if(Ice::Variable *var = llvm::dyn_cast<Ice::Variable>(src)) in deleteInstruction()
532 bool Optimizer::isDead(Ice::Inst *instruction) in isDead()
534 Ice::Variable *dest = instruction->getDest(); in isDead()
542 if(Ice::Variable *address = llvm::dyn_cast<Ice::Variable>(storeAddress(instruction))) in isDead()
544 Ice::Inst *def = getDefinition(address); in isDead()
546 if(def && llvm::isa<Ice::InstAlloca>(def)) in isDead()
564 const Ice::InstIntrinsicCall *Optimizer::asLoadSubVector(const Ice::Inst *instruction) in asLoadSubVector()
566 if(auto *instrinsic = llvm::dyn_cast<Ice::InstIntrinsicCall>(instruction)) in asLoadSubVector()
568 if(instrinsic->getIntrinsicInfo().ID == Ice::Intrinsics::LoadSubVector) in asLoadSubVector()
577 const Ice::InstIntrinsicCall *Optimizer::asStoreSubVector(const Ice::Inst *instruction) in asStoreSubVector()
579 if(auto *instrinsic = llvm::dyn_cast<Ice::InstIntrinsicCall>(instruction)) in asStoreSubVector()
581 if(instrinsic->getIntrinsicInfo().ID == Ice::Intrinsics::StoreSubVector) in asStoreSubVector()
590 bool Optimizer::isLoad(const Ice::Inst &instruction) in isLoad()
592 if(llvm::isa<Ice::InstLoad>(&instruction)) in isLoad()
600 bool Optimizer::isStore(const Ice::Inst &instruction) in isStore()
602 if(llvm::isa<Ice::InstStore>(&instruction)) in isStore()
610 Ice::Operand *Optimizer::storeAddress(const Ice::Inst *instruction) in storeAddress()
614 if(auto *store = llvm::dyn_cast<Ice::InstStore>(instruction)) in storeAddress()
627 Ice::Operand *Optimizer::loadAddress(const Ice::Inst *instruction) in loadAddress()
631 if(auto *load = llvm::dyn_cast<Ice::InstLoad>(instruction)) in loadAddress()
644 Ice::Operand *Optimizer::storeData(const Ice::Inst *instruction) in storeData()
648 if(auto *store = llvm::dyn_cast<Ice::InstStore>(instruction)) in storeData()
661 std::size_t Optimizer::storeSize(const Ice::Inst *store) in storeSize()
665 if(auto *instStore = llvm::dyn_cast<Ice::InstStore>(store)) in storeSize()
667 return Ice::typeWidthInBytes(instStore->getData()->getType()); in storeSize()
672 return llvm::cast<Ice::ConstantInteger32>(storeSubVector->getSrc(3))->getValue(); in storeSize()
678 bool Optimizer::loadTypeMatchesStore(const Ice::Inst *load, const Ice::Inst *store) in loadTypeMatchesStore()
688 if(auto *instStore = llvm::dyn_cast<Ice::InstStore>(store)) in loadTypeMatchesStore()
690 if(auto *instLoad = llvm::dyn_cast<Ice::InstLoad>(load)) in loadTypeMatchesStore()
702 llvm::cast<Ice::ConstantInteger32>(storeSubVector->getSrc(3))->getValue() == in loadTypeMatchesStore()
703 llvm::cast<Ice::ConstantInteger32>(loadSubVector->getSrc(2))->getValue(); in loadTypeMatchesStore()
710 Optimizer::Uses* Optimizer::getUses(Ice::Operand* operand) in getUses()
712 Optimizer::Uses* uses = (Optimizer::Uses*)operand->Ice::Operand::getExternalData(); in getUses()
722 void Optimizer::setUses(Ice::Operand* operand, Optimizer::Uses* uses) in setUses()
724 operand->Ice::Operand::setExternalData(uses); in setUses()
727 bool Optimizer::hasUses(Ice::Operand* operand) const in hasUses()
729 return operand->Ice::Operand::getExternalData() != nullptr; in hasUses()
732 Ice::CfgNode* Optimizer::getNode(Ice::Inst* inst) in getNode()
734 return (Ice::CfgNode*)inst->Ice::Inst::getExternalData(); in getNode()
737 void Optimizer::setNode(Ice::Inst* inst, Ice::CfgNode* node) in setNode()
739 inst->Ice::Inst::setExternalData(node); in setNode()
742 Ice::Inst* Optimizer::getDefinition(Ice::Variable* var) in getDefinition()
744 return (Ice::Inst*)var->Ice::Variable::getExternalData(); in getDefinition()
747 void Optimizer::setDefinition(Ice::Variable* var, Ice::Inst* inst) in setDefinition()
749 var->Ice::Variable::setExternalData(inst); in setDefinition()
752 const std::vector<Optimizer::LoadStoreInst>& Optimizer::getLoadStoreInsts(Ice::CfgNode* node) in getLoadStoreInsts()
754 return *((const std::vector<LoadStoreInst>*)node->Ice::CfgNode::getExternalData()); in getLoadStoreInsts()
757 void Optimizer::setLoadStoreInsts(Ice::CfgNode* node, std::vector<LoadStoreInst>* insts) in setLoadStoreInsts()
759 node->Ice::CfgNode::setExternalData(insts); in setLoadStoreInsts()
762 bool Optimizer::hasLoadStoreInsts(Ice::CfgNode* node) const in hasLoadStoreInsts()
764 return node->Ice::CfgNode::getExternalData() != nullptr; in hasLoadStoreInsts()
772 void Optimizer::Uses::insert(Ice::Operand *value, Ice::Inst *instruction) in insert()
792 void Optimizer::Uses::erase(Ice::Inst *instruction) in erase()
831 void optimize(Ice::Cfg *function) in optimize()