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

Method IsConditionCheckSideEffectFree

source/opt/loop_peeling.cpp:232–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232bool LoopPeeling::IsConditionCheckSideEffectFree() const {
233 CFG& cfg = *context_->cfg();
234
235 // The "do-while" form does not cause issues, the algorithm takes into account
236 // the first iteration.
237 if (!do_while_form_) {
238 uint32_t condition_block_id = cfg.preds(loop_->GetMergeBlock()->id())[0];
239
240 std::unordered_set<uint32_t> blocks_in_path;
241
242 blocks_in_path.insert(condition_block_id);
243 GetBlocksInPath(condition_block_id, loop_->GetHeaderBlock()->id(),
244 &blocks_in_path, cfg);
245
246 for (uint32_t bb_id : blocks_in_path) {
247 BasicBlock* bb = cfg.block(bb_id);
248 if (!bb->WhileEachInst([this](Instruction* insn) {
249 if (insn->IsBranch()) return true;
250 switch (insn->opcode()) {
251 case spv::Op::OpLabel:
252 case spv::Op::OpSelectionMerge:
253 case spv::Op::OpLoopMerge:
254 return true;
255 default:
256 break;
257 }
258 return context_->IsCombinatorInstruction(insn);
259 })) {
260 return false;
261 }
262 }
263 }
264
265 return true;
266}
267
268void LoopPeeling::GetIteratingExitValues() {
269 CFG& cfg = *context_->cfg();

Callers

nothing calls this directly

Calls 11

GetBlocksInPathFunction · 0.85
GetMergeBlockMethod · 0.80
IsBranchMethod · 0.80
cfgMethod · 0.45
idMethod · 0.45
insertMethod · 0.45
GetHeaderBlockMethod · 0.45
blockMethod · 0.45
WhileEachInstMethod · 0.45
opcodeMethod · 0.45

Tested by

no test coverage detected