| 373 | } |
| 374 | |
| 375 | bool ScalarEvolutionAnalysis::IsLoopInvariant(const Loop* loop, |
| 376 | const SENode* node) const { |
| 377 | for (auto itr = node->graph_cbegin(); itr != node->graph_cend(); ++itr) { |
| 378 | if (const SERecurrentNode* rec = itr->AsSERecurrentNode()) { |
| 379 | const BasicBlock* header = rec->GetLoop()->GetHeaderBlock(); |
| 380 | |
| 381 | // If the loop which the recurrent expression belongs to is either |loop |
| 382 | // or a nested loop inside |loop| then we assume it is variant. |
| 383 | if (loop->IsInsideLoop(header)) { |
| 384 | return false; |
| 385 | } |
| 386 | } else if (const SEValueUnknown* unknown = itr->AsSEValueUnknown()) { |
| 387 | // If the instruction is inside the loop we conservatively assume it is |
| 388 | // loop variant. |
| 389 | if (loop->IsInsideLoop(unknown->ResultId())) return false; |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | return true; |
| 394 | } |
| 395 | |
| 396 | SENode* ScalarEvolutionAnalysis::GetCoefficientFromRecurrentTerm( |
| 397 | SENode* node, const Loop* loop) { |
no test coverage detected