mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-25 01:01:04 +00:00
Revert "Opt: LocalBlockElim: Add HasOnlySupportedRefs"
This reverts commit 2d0f7fbc11
.
This commit is contained in:
parent
2d0f7fbc11
commit
df96e243c6
@ -231,6 +231,7 @@ bool AggressiveDCEPass::AggressiveDCE(ir::Function* func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AggressiveDCEPass::Initialize(ir::Module* module) {
|
void AggressiveDCEPass::Initialize(ir::Module* module) {
|
||||||
|
|
||||||
module_ = module;
|
module_ = module;
|
||||||
|
|
||||||
// Initialize id-to-function map
|
// Initialize id-to-function map
|
||||||
|
@ -218,24 +218,6 @@ void LocalSingleBlockLoadStoreElimPass::DCEInst(ir::Instruction* inst) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalSingleBlockLoadStoreElimPass::HasOnlySupportedRefs(uint32_t ptrId) {
|
|
||||||
if (supported_ref_ptrs_.find(ptrId) != supported_ref_ptrs_.end())
|
|
||||||
return true;
|
|
||||||
analysis::UseList* uses = def_use_mgr_->GetUses(ptrId);
|
|
||||||
assert(uses != nullptr);
|
|
||||||
for (auto u : *uses) {
|
|
||||||
SpvOp op = u.inst->opcode();
|
|
||||||
if (IsNonPtrAccessChain(op)) {
|
|
||||||
if (!HasOnlySupportedRefs(u.inst->result_id()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
supported_ref_ptrs_.insert(ptrId);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LocalSingleBlockLoadStoreElimPass::LocalSingleBlockLoadStoreElim(
|
bool LocalSingleBlockLoadStoreElimPass::LocalSingleBlockLoadStoreElim(
|
||||||
ir::Function* func) {
|
ir::Function* func) {
|
||||||
// Perform local store/load and load/load elimination on each block
|
// Perform local store/load and load/load elimination on each block
|
||||||
@ -252,8 +234,6 @@ bool LocalSingleBlockLoadStoreElimPass::LocalSingleBlockLoadStoreElim(
|
|||||||
ir::Instruction* ptrInst = GetPtr(&*ii, &varId);
|
ir::Instruction* ptrInst = GetPtr(&*ii, &varId);
|
||||||
if (!IsTargetVar(varId))
|
if (!IsTargetVar(varId))
|
||||||
continue;
|
continue;
|
||||||
if (!HasOnlySupportedRefs(varId))
|
|
||||||
continue;
|
|
||||||
// Register the store
|
// Register the store
|
||||||
if (ptrInst->opcode() == SpvOpVariable) {
|
if (ptrInst->opcode() == SpvOpVariable) {
|
||||||
// if not pinned, look for WAW
|
// if not pinned, look for WAW
|
||||||
@ -278,8 +258,6 @@ bool LocalSingleBlockLoadStoreElimPass::LocalSingleBlockLoadStoreElim(
|
|||||||
ir::Instruction* ptrInst = GetPtr(&*ii, &varId);
|
ir::Instruction* ptrInst = GetPtr(&*ii, &varId);
|
||||||
if (!IsTargetVar(varId))
|
if (!IsTargetVar(varId))
|
||||||
continue;
|
continue;
|
||||||
if (!HasOnlySupportedRefs(varId))
|
|
||||||
continue;
|
|
||||||
// Look for previous store or load
|
// Look for previous store or load
|
||||||
uint32_t replId = 0;
|
uint32_t replId = 0;
|
||||||
if (ptrInst->opcode() == SpvOpVariable) {
|
if (ptrInst->opcode() == SpvOpVariable) {
|
||||||
@ -342,9 +320,6 @@ void LocalSingleBlockLoadStoreElimPass::Initialize(ir::Module* module) {
|
|||||||
seen_target_vars_.clear();
|
seen_target_vars_.clear();
|
||||||
seen_non_target_vars_.clear();
|
seen_non_target_vars_.clear();
|
||||||
|
|
||||||
// Clear collections
|
|
||||||
supported_ref_ptrs_.clear();
|
|
||||||
|
|
||||||
// TODO(): Reuse def/use from previous passes
|
// TODO(): Reuse def/use from previous passes
|
||||||
def_use_mgr_.reset(new analysis::DefUseManager(consumer(), module_));
|
def_use_mgr_.reset(new analysis::DefUseManager(consumer(), module_));
|
||||||
|
|
||||||
|
@ -85,10 +85,6 @@ class LocalSingleBlockLoadStoreElimPass : public Pass {
|
|||||||
// labels.
|
// labels.
|
||||||
void DCEInst(ir::Instruction* inst);
|
void DCEInst(ir::Instruction* inst);
|
||||||
|
|
||||||
// Return true if all uses of |varId| are only through supported reference
|
|
||||||
// operations ie. loads and store. Also cache in supported_ref_ptrs_;
|
|
||||||
bool HasOnlySupportedRefs(uint32_t varId);
|
|
||||||
|
|
||||||
// On all entry point functions, within each basic block, eliminate
|
// On all entry point functions, within each basic block, eliminate
|
||||||
// loads and stores to function variables where possible. For
|
// loads and stores to function variables where possible. For
|
||||||
// loads, if previous load or store to same variable, replace
|
// loads, if previous load or store to same variable, replace
|
||||||
@ -146,10 +142,6 @@ class LocalSingleBlockLoadStoreElimPass : public Pass {
|
|||||||
// from this set each time a new store of that variable is encountered.
|
// from this set each time a new store of that variable is encountered.
|
||||||
std::unordered_set<uint32_t> pinned_vars_;
|
std::unordered_set<uint32_t> pinned_vars_;
|
||||||
|
|
||||||
// Variables that are only referenced by supported operations for this
|
|
||||||
// pass ie. loads and stores.
|
|
||||||
std::unordered_set<uint32_t> supported_ref_ptrs_;
|
|
||||||
|
|
||||||
// Next unused ID
|
// Next unused ID
|
||||||
uint32_t next_id_;
|
uint32_t next_id_;
|
||||||
};
|
};
|
||||||
|
@ -184,7 +184,8 @@ class LocalMultiStoreElimPass : public Pass {
|
|||||||
// the runtime and effectiveness of this function.
|
// the runtime and effectiveness of this function.
|
||||||
bool EliminateMultiStoreLocal(ir::Function* func);
|
bool EliminateMultiStoreLocal(ir::Function* func);
|
||||||
|
|
||||||
// Return true if |op| is decorate.
|
// Return true if all uses of varId are only through supported reference
|
||||||
|
// operations ie. loads and store. Also cache in supported_ref_vars_;
|
||||||
inline bool IsDecorate(uint32_t op) const {
|
inline bool IsDecorate(uint32_t op) const {
|
||||||
return (op == SpvOpDecorate || op == SpvOpDecorateId);
|
return (op == SpvOpDecorate || op == SpvOpDecorateId);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user