[llvm-dev] ind variable

Anastasiya Ruzhanskaya via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 9 05:18:20 PDT 2017


Hello,
I have this piece of code:
int main() {
        int m = 0;
//      int i, j, k;
//      int N = f()%10;
        for (int l = 0; l < 1000; l+=4)
                printf("%d", l);

I am sure, that llvm is capable to convert this into canonical induction
variable, but even with O3
define i32 @main() #0 {
  br label %2

; <label>:1                                       ; preds = %2
  ret i32 0

; <label>:2                                       ; preds = %0, %2
  %l.01 = phi i32 [ 0, %0 ], [ %4, %2 ]
  %3 = tail call i32 (i8*, ...) @printf(i8* nonnull getelementptr inbounds
([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %l.01)
  %4 = add nuw nsw i32 %l.01, 4
  %5 = icmp slt i32 %4, 1000
  br i1 %5, label %2, label %1
}

I have this assembler.
I know there is indvars2 pass ( it is under llvm license but used only in
LegUp project - as I understood, surfing the Internet), which is good in
changing induction variables.

How can I achieve that this cycle will have a canonical indvar?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170809/f5171247/attachment.html>


More information about the llvm-dev mailing list