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

Method CheckCondition

source/opt/loop_fusion.cpp:269–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267}
268
269bool LoopFusion::CheckCondition() {
270 auto condition_0 = loop_0_->GetConditionInst();
271 auto condition_1 = loop_1_->GetConditionInst();
272
273 if (!loop_0_->IsSupportedCondition(condition_0->opcode()) ||
274 !loop_1_->IsSupportedCondition(condition_1->opcode())) {
275 return false;
276 }
277
278 if (condition_0->opcode() != condition_1->opcode()) {
279 return false;
280 }
281
282 for (uint32_t i = 0; i < condition_0->NumInOperandWords(); ++i) {
283 auto arg_0 = context_->get_def_use_mgr()->GetDef(
284 condition_0->GetSingleWordInOperand(i));
285 auto arg_1 = context_->get_def_use_mgr()->GetDef(
286 condition_1->GetSingleWordInOperand(i));
287
288 if (arg_0 == induction_0_ && arg_1 == induction_1_) {
289 continue;
290 }
291
292 if (arg_0 == induction_0_ && arg_1 != induction_1_) {
293 return false;
294 }
295
296 if (arg_1 == induction_1_ && arg_0 != induction_0_) {
297 return false;
298 }
299
300 if (arg_0 != arg_1) {
301 return false;
302 }
303 }
304
305 return true;
306}
307
308bool LoopFusion::CheckStep() {
309 auto scalar_analysis = context_->GetScalarEvolutionAnalysis();

Callers

nothing calls this directly

Calls 7

GetConditionInstMethod · 0.80
IsSupportedConditionMethod · 0.80
NumInOperandWordsMethod · 0.80
opcodeMethod · 0.45
GetDefMethod · 0.45
get_def_use_mgrMethod · 0.45

Tested by

no test coverage detected