| 89 | } |
| 90 | |
| 91 | std::vector<instruction_ref> find_splits() const |
| 92 | { |
| 93 | std::vector<instruction_ref> result; |
| 94 | copy_if(iterator_for(*rm), std::back_inserter(result), [](auto ins) { |
| 95 | return is_reduce(*ins); |
| 96 | }); |
| 97 | if(result.size() > 2) |
| 98 | return {}; |
| 99 | // Only handle reduce_sum for now |
| 100 | // TODO: Support other reduction types |
| 101 | if(not std::all_of(result.begin(), result.end(), [](instruction_ref ins) { |
| 102 | return ins->name() == "reduce_sum"; |
| 103 | })) |
| 104 | return {}; |
| 105 | if(result.size() < 2) |
| 106 | return result; |
| 107 | if(reaches(result[0], result[1])) |
| 108 | return {}; |
| 109 | return result; |
| 110 | } |
| 111 | |
| 112 | std::vector<instruction_ref> find_alive(const std::vector<instruction_ref>& splits) |
| 113 | { |