| 450 | } |
| 451 | |
| 452 | bool LoopDependenceAnalysis::IsSupportedLoop(const Loop* loop) { |
| 453 | std::vector<Instruction*> inductions{}; |
| 454 | loop->GetInductionVariables(inductions); |
| 455 | if (inductions.size() != 1) { |
| 456 | return false; |
| 457 | } |
| 458 | Instruction* induction = inductions[0]; |
| 459 | SENode* induction_node = scalar_evolution_.SimplifyExpression( |
| 460 | scalar_evolution_.AnalyzeInstruction(induction)); |
| 461 | if (!induction_node->AsSERecurrentNode()) { |
| 462 | return false; |
| 463 | } |
| 464 | SENode* induction_step = |
| 465 | induction_node->AsSERecurrentNode()->GetCoefficient(); |
| 466 | if (!induction_step->AsSEConstantNode()) { |
| 467 | return false; |
| 468 | } |
| 469 | if (!(induction_step->AsSEConstantNode()->FoldToSingleValue() == 1 || |
| 470 | induction_step->AsSEConstantNode()->FoldToSingleValue() == -1)) { |
| 471 | return false; |
| 472 | } |
| 473 | return true; |
| 474 | } |
| 475 | |
| 476 | void LoopDependenceAnalysis::PrintDebug(std::string debug_msg) { |
| 477 | if (debug_stream_) { |
no test coverage detected