MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / RewriteUse

Method RewriteUse

source/opt/loop_utils.cpp:71–89  ·  view source on GitHub ↗

Rewrites the use of |def_insn_| by the instruction |user| at the index |operand_index| in terms of phi instruction. This recursively builds new phi instructions from |user| to the loop exit blocks' phis. The use of |def_insn_| in |user| is replaced by the relevant phi instruction at the end of the operation. It is assumed that |user| does not dominates any of the loop exit basic block. This operat

Source from the content-addressed store, hash-verified

69 // records what needs to be updated. The actual update is performed by
70 // UpdateManagers.
71 bool RewriteUse(BasicBlock* bb, Instruction* user, uint32_t operand_index) {
72 assert(
73 (user->opcode() != spv::Op::OpPhi || bb != GetParent(user)) &&
74 "The root basic block must be the incoming edge if |user| is a phi "
75 "instruction");
76 assert((user->opcode() == spv::Op::OpPhi || bb == GetParent(user)) &&
77 "The root basic block must be the instruction parent if |user| is "
78 "not "
79 "phi instruction");
80
81 Instruction* new_def = GetOrBuildIncoming(bb->id());
82 if (!new_def) {
83 return false;
84 }
85
86 user->SetOperand(operand_index, {new_def->result_id()});
87 rewritten_.insert(user);
88 return true;
89 }
90
91 // In-place update of some managers (avoid full invalidation).
92 inline void UpdateManagers() {

Callers 1

MakeSetClosedSSAFunction · 0.80

Calls 5

SetOperandMethod · 0.80
opcodeMethod · 0.45
idMethod · 0.45
result_idMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected