| 230 | } |
| 231 | |
| 232 | bool 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 | |
| 268 | void LoopPeeling::GetIteratingExitValues() { |
| 269 | CFG& cfg = *context_->cfg(); |
nothing calls this directly
no test coverage detected