Check if node is affine, ie in the form: a0*i0 + a1*i1 + ... an*in + c and contains only the following types of nodes: SERecurrentNode, SEAddNode and SEConstantNode
| 69 | // and contains only the following types of nodes: SERecurrentNode, SEAddNode |
| 70 | // and SEConstantNode |
| 71 | bool IsInCorrectFormForGCDTest(SENode* node) { |
| 72 | bool children_ok = true; |
| 73 | |
| 74 | if (auto add_node = node->AsSEAddNode()) { |
| 75 | for (auto child : add_node->GetChildren()) { |
| 76 | children_ok &= IsInCorrectFormForGCDTest(child); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | bool this_ok = node->AsSERecurrentNode() || node->AsSEAddNode() || |
| 81 | node->AsSEConstantNode(); |
| 82 | |
| 83 | return children_ok && this_ok; |
| 84 | } |
| 85 | |
| 86 | // If |node| is an SERecurrentNode then returns |node| or if |node| is an |
| 87 | // SEAddNode returns a vector of SERecurrentNode that are its children. |
no test coverage detected