| 1178 | */ |
| 1179 | |
| 1180 | Pass::Status LoopUnroller::Process() { |
| 1181 | bool changed = false; |
| 1182 | for (Function& f : *context()->module()) { |
| 1183 | if (f.IsDeclaration()) { |
| 1184 | continue; |
| 1185 | } |
| 1186 | |
| 1187 | LoopDescriptor* LD = context()->GetLoopDescriptor(&f); |
| 1188 | for (Loop& loop : *LD) { |
| 1189 | LoopUtils loop_utils{context(), &loop}; |
| 1190 | if (!loop.HasUnrollLoopControl() || !loop_utils.CanPerformUnroll()) { |
| 1191 | continue; |
| 1192 | } |
| 1193 | |
| 1194 | if (fully_unroll_) { |
| 1195 | if (!loop_utils.FullyUnroll()) { |
| 1196 | return Status::Failure; |
| 1197 | } |
| 1198 | changed = true; |
| 1199 | } else { |
| 1200 | if (!loop_utils.PartiallyUnroll(unroll_factor_)) { |
| 1201 | return Status::Failure; |
| 1202 | } |
| 1203 | changed = true; |
| 1204 | } |
| 1205 | } |
| 1206 | LD->PostModificationCleanup(); |
| 1207 | } |
| 1208 | |
| 1209 | if (changed) { |
| 1210 | context()->InvalidateAnalysesExceptFor( |
| 1211 | IRContext::Analysis::kAnalysisLoopAnalysis); |
| 1212 | } |
| 1213 | |
| 1214 | return changed ? Status::SuccessWithChange : Status::SuccessWithoutChange; |
| 1215 | } |
| 1216 | |
| 1217 | } // namespace opt |
| 1218 | } // namespace spvtools |
nothing calls this directly
no test coverage detected