Skip to content

Commit

Permalink
Simplify fixed loop size heuristics
Browse files Browse the repository at this point in the history
  • Loading branch information
karoliineh committed Sep 27, 2024
1 parent 3e59210 commit 135deb5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/util/loopUnrolling.ml
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,11 @@ let loop_unrolling_factor loopStatement func totalLoops =
Found -> true
in
(*unroll up to near an instruction count, higher if the loop uses malloc/lock/threads *)
let targetInstructions = if unrollFunctionCalled then 50 else 25 in
let loopStats = AutoTune0.collectFactors visitCilStmt loopStatement in
if loopStats.instructions > 0 then
let fixedLoop = fixedLoopSize loopStatement func in
(* Unroll at least 10 times if there are only few (17?) loops *)
let unroll_min = if totalLoops < 17 && AutoTune0.isActivated "forceLoopUnrollForFewLoops" then 10 else 0 in
match fixedLoop with
| Some i when i <= 100 -> Logs.debug "fixed loop size"; i
| _ -> max unroll_min (targetInstructions / loopStats.instructions)
match fixedLoopSize loopStatement func with
| Some i when i <= 20 -> Logs.debug "fixed loop size %d" i; i
| _ -> 4
else
(* Don't unroll empty (= while(1){}) loops*)
0
Expand Down

0 comments on commit 135deb5

Please sign in to comment.