Hi, Is the -indvars pass functional? I've done some small test to check it, but this fails to canonicalize:> int *x; > int *y; > int i; > ... > for (i = 1; i < 100; i+=2) { > x[i] = y[i] + 3; > }The IR produced after -indvars:> br label %for.cond > > for.cond: ; preds = %for.inc, %entry > %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 1, %entry ] > %0 = trunc i64 %indvars.iv to i32 > %cmp = icmp slt i32 %0, 100 > br i1 %cmp, label %for.body, label %for.end > > for.body: ; preds = %for.cond > %arrayidx = getelementptr inbounds i32* %y, i64 %indvars.iv > %1 = load i32* %arrayidx, align 4 > %add = add nsw i32 %1, 3 > %arrayidx2 = getelementptr inbounds i32* %x, i64 %indvars.iv > store i32 %add, i32* %arrayidx2, align 4 > br label %for.inc > > for.inc: ; preds = %for.body > %indvars.iv.next = add i64 %indvars.iv, 2 > br label %for.cond > > for.end: ; preds = %for.condWhich isn't in canonical form. Is there some trick to getting this pass to work? I've tried adding various other passes ahead of it, like -aa-eval, -scalar-evolution, -mem2reg, -lcssa, -loop-simplify, etc but to no avail. Thank you, Gavin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120308/0aaeb898/attachment.html>
On 03/08/2012 06:23 PM, Gavin Harrison wrote:> Hi, > > Is the -indvars pass functional? I've done some small test to check it, > but this fails to canonicalize: > >> int *x; >> int *y; >> int i; >> ... >> for (i = 1; i < 100; i+=2) { >> x[i] = y[i] + 3; >> } > > The IR produced after -indvars: > >> br label %for.cond >> >> for.cond: ; preds = %for.inc, %entry >> %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 1, %entry ] >> %0 = trunc i64 %indvars.iv to i32 >> %cmp = icmp slt i32 %0, 100 >> br i1 %cmp, label %for.body, label %for.end >> >> for.body: ; preds = %for.cond >> %arrayidx = getelementptr inbounds i32* %y, i64 %indvars.iv >> %1 = load i32* %arrayidx, align 4 >> %add = add nsw i32 %1, 3 >> %arrayidx2 = getelementptr inbounds i32* %x, i64 %indvars.iv >> store i32 %add, i32* %arrayidx2, align 4 >> br label %for.inc >> >> for.inc: ; preds = %for.body >> %indvars.iv.next = add i64 %indvars.iv, 2 >> br label %for.cond >> >> for.end: ; preds = %for.cond > > Which isn't in canonical form. Is there some trick to getting this pass > to work? I've tried adding various other passes ahead of it, like > -aa-eval, -scalar-evolution, -mem2reg, -lcssa, -loop-simplify, etc but > to no avail.-indvars does not canonicalize as much any more, as more passes can handle non canonical loops. To get the old canonicalization add -enable-iv-rewrite on the command line. Though I would not rely on this, as this flag is about to be removed. Cheers Tobi
It seems there is no -enable-iv-rewrite now in llvm3.2, and it suggest -enable-load-pre, but it still does not work. So, how to active the transform? -- View this message in context: http://llvm.1065342.n5.nabble.com/indvars-issues-tp4646p58587.html Sent from the LLVM - Dev mailing list archive at Nabble.com.