Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect fixed loops with autotuner even if there is no assignment of const value to the loop variable before loop #1516

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/util/loopUnrolling.ml
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ let fixedLoopSize loopStatement func =
if getsPointedAt var func then
None
else
let* start = constBefore var loopStatement func in
let* diff = assignmentDifference (loopBody loopStatement) var in
let diff = Option.value (assignmentDifference (loopBody loopStatement) var) ~default:Z.one in
(* Assume var start value if there was no constant assignment to the var before loop;
Assume it to be 0, if loop is increasing and 11 (TODO: can we do better than just 11?) if loop is decreasing *)
let start = Option.value (constBefore var loopStatement func) ~default:(if diff < Z.zero then Z.of_int 11 else Z.zero) in
let* goal = adjustGoal diff goal op in
let iterations = loopIterations start diff goal (op=Ne) in
Logs.debug "comparison: %a" CilType.Exp.pretty comparison;
Expand Down
Loading