Skip to content

Commit ae2d9d5

Browse files
committed
Call findAssignmentConstDiff on loops body instead the loop itself
1 parent 48967ad commit ae2d9d5

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/util/loopUnrolling.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ let fixedLoopSize loopStatement func =
253253
in let assignmentDifference loop var = try
254254
let diff = ref None in
255255
let visitor = new findAssignmentConstDiff(diff, var) in
256-
ignore @@ visitCilStmt visitor loop;
256+
ignore @@ visitCilBlock visitor loop;
257257
!diff
258258
with | WrongOrMultiple -> None
259259
in
@@ -264,7 +264,7 @@ let fixedLoopSize loopStatement func =
264264
None
265265
else
266266
constBefore var loopStatement func >>= fun start ->
267-
assignmentDifference loopStatement var >>= fun diff ->
267+
assignmentDifference (loopBody loopStatement) var >>= fun diff ->
268268
Logs.debug "comparison: ";
269269
Pretty.fprint stderr (dn_exp () comparison) ~width:max_int;
270270
Logs.debug "";
@@ -344,7 +344,7 @@ let loop_unrolling_factor loopStatement func totalLoops =
344344
(* Unroll at least 10 times if there are only few (17?) loops *)
345345
let unroll_min = if totalLoops < 17 && AutoTune0.isActivated "forceLoopUnrollForFewLoops" then 10 else 0 in
346346
match fixedLoop with
347-
| Some i -> if i * loopStats.instructions < 100 then (Logs.debug "fixed loop size"; i) else max unroll_min (100 / loopStats.instructions)
347+
| Some i -> if i * loopStats.instructions < 100 || totalLoops < 10 then (Logs.debug "fixed loop size"; i) else max unroll_min (100 / loopStats.instructions)
348348
| _ -> max unroll_min (targetInstructions / loopStats.instructions)
349349
else
350350
(* Don't unroll empty (= while(1){}) loops*)

0 commit comments

Comments
 (0)