May 2015
Intermediate to advanced
296 pages
5h 10m
English
In this recipe, we will see how we can transform and optimize loops to get shorter execution times. We will mainly be looking into the Loop-Invariant Code Motion (LICM) optimization technique, and see how it works and how it transforms the code. We will also look at a relatively simpler technique called loop deletion, where we eliminate loops with non-infinite, computable trip counts that have no side effects on a function's return value.
You must have the opt tool built for this recipe.
$ cat testlicm.ll define void @testfunc(i32 %i) { ; <label>:0 br label %Loop Loop: ; preds = %Loop, %0 %j = phi i32 [ 0, %0 ], [ %Next, %Loop ] ; <i32> [#uses=1] ...
Read now
Unlock full access