[LLVMdev] regarding opt -indvars
Edvard Ghazaryan
edvard_gh at yahoo.com
Tue Jul 24 15:49:50 PDT 2012
Hello .
I ran opt with -indvars options , got wrong result.
This is my example:
test.cc :
int test(int a)
{
for (int i = 2; i < a; ++i) {
a += ;
}
return a;
}
clang -O3 -emit-llvm -S test.cc -o test.ll
opt -indvards -S test.ll -o indvars.ll > /dev/null
indvars.ll :
; ModuleID = 'test.ll'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
target triple = "i386-pc-linux-gnu"
define i32 @_Z4testi(i32 %a) nounwind readnone {
entry:
%cmp1 = icmp sgt i32 %a, 2
br i1 %cmp1, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %entry
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
%a.addr.03 = phi i32 [ %add, %for.body ], [ %a, %for.body.preheader ] //should start at 0 , I think there is no Canonicalize Induction Variable
%i.02 = phi i32 [ %inc, %for.body ], [ 2, %for.body.preheader ]
%add = add nsw i32 %a.addr.03, %i.02
%inc = add nsw i32 %i.02, 1
%cmp = icmp slt i32 %inc, %add
br i1 %cmp, label %for.body, label %for.end.loopexit
for.end.loopexit: ; preds = %for.body
%add.lcssa = phi i32 [ %add, %for.body ]
br label %for.end
for.end: ; preds = %for.end.loopexit, %entry
%a.addr.0.lcssa = phi i32 [ %a, %entry ], [ %add.lcssa, %for.end.loopexit ]
ret i32 %a.addr.0.lcssa
}
Someone can explain why?
Thanks in advance,
Edvard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120724/eee664d3/attachment.html>
More information about the llvm-dev
mailing list