Detect fixed loops with autotuner even if there is no assignment of const value to the loop variable before loop #1516
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In SV-COMP no-overflow tasks there are cases similar to the following example:
where the loop has a fixed size of iterations from
i == 0
toi == 99
, which the autotuner is unable to detect because it only relies on finding the starting value through assignments.As the CIL representation of the if-statement
if (!(i==0 && j==0)) return 0;
is too complicated to extract the value from there, I opted for assuming that if the variable is not assigned to a constant value before the loop, its' value is 0 (or 11, if the loop is decreasing).Similarly, I propose assuming that the diff is 1 if it is not found, as loops are more often increasing the start value than decreasing.
This revealed another bug, which makes me wonder if the autotuner even was ever able to find any fixed-size loops previously, as it checked for the condition:using the loop statement itself, not its body, making it always think that there is a nested loop present that is also modifying the loop variable.Also, loops with size 100 were deemed too big to unroll if there were more than 0 instructions (function calls or assignments) in the loop.