Skip to content

Commit 508e8a5

Browse files
committed
improve handling of constant loops
1 parent 8208cf6 commit 508e8a5

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ To install or update LODA, please follow the [installation instructions](https:/
22

33
## [Unreleased]
44

5+
### Enhancements
6+
7+
* Improve handling of loops with constant number of iterations
8+
59
# v22.6.19
610

711
### Features

src/finder.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,10 @@ std::pair<std::string, steps_t> Finder::isOptimizedBetter(
293293
}
294294

295295
// check if there are loops with contant number of iterations involved
296-
const int64_t const_loops_existing =
297-
ProgramUtil::hasLoopWithConstantNumIterations(existing);
298-
const int64_t const_loops_optimized =
299-
ProgramUtil::hasLoopWithConstantNumIterations(optimized);
300-
if (const_loops_optimized < const_loops_existing) {
301-
result.first = "Simpler";
296+
if (ProgramUtil::hasLoopWithConstantNumIterations(optimized)) {
297+
// independently of the existing program, we stop here because
298+
// otherwise it yields fake optimization of constant loops
302299
return result;
303-
} else if (const_loops_optimized > const_loops_existing) {
304-
return result; // worse
305300
}
306301

307302
// get extended sequence

0 commit comments

Comments
 (0)