[LLVMbugs] [Bug 1722] New: -indvars does not rewrite the exit condition for a two-level loop nest
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Tue Oct 2 12:14:53 PDT 2007
http://llvm.org/bugs/show_bug.cgi?id=1722
Summary: -indvars does not rewrite the exit condition for a two-
level loop nest
Product: libraries
Version: 2.1
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P2
Component: Loop Optimizer
AssignedTo: unassignedbugs at nondot.org
ReportedBy: zhiruz at gmail.com
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=1151)
--> (http://llvm.org/bugs/attachment.cgi?id=1151)
foo.bc
//////// C code ////////////////
void foo()
{
int i, j;
for (i = 0; i < 100; ++i)
for (j = 0; j < i; ++j)
a[i][j] = i * j;
}
;;;;;;;;;;;;;;;;; ll code piece for the loop nest ;;;;;;;;;;;;;;;;;;;;;;
bb1: ; preds = %bb10
%tmp5 = mul i32 %i.0, %j.1 ; <i32> [#uses=1]
%tmp7 = getelementptr [100 x [100 x i32]]* @a, i32 0, i32 %i.0, i32
%j.1 ; <i32*> [#uses=1]
store i32 %tmp5, i32* %tmp7, align 4
%tmp9 = add i32 %j.1, 1 ; <i32> [#uses=1]
br label %bb10
bb10: ; preds = %bb18, %bb1
%j.1 = phi i32 [ %tmp9, %bb1 ], [ 0, %bb18 ] ; <i32>
[#uses=4]
%tmp13 = icmp slt i32 %j.1, %i.0 ; <i1> [#uses=1]
br i1 %tmp13, label %bb1, label %bb15
bb15: ; preds = %bb10
%tmp17 = add i32 %i.0, 1 ; <i32> [#uses=1]
br label %bb18
bb18: ; preds = %bb15, %entry
%i.0 = phi i32 [ 0, %entry ], [ %tmp17, %bb15 ] ; <i32>
[#uses=5]
%tmp20 = icmp slt i32 %i.0, 100 ; <i1> [#uses=1]
br i1 %tmp20, label %bb10, label %return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
After "opt -indvars -simplifycfg",
;;;;;;;;;;;;;;;;; ll code piece after -indvars ;;;;;;;;;;;;;;;;;;;;;;
bb1: ; preds = %bb10
%tmp5 = mul i32 %i.0, %j.1 ; <i32> [#uses=1]
%tmp7 = getelementptr [100 x [100 x i32]]* @a, i32 0, i32 %i.0, i32
%j.1 ; <i32*> [#uses=1]
store i32 %tmp5, i32* %tmp7, align 4
%indvar.next = add i32 %j.1, 1 ; <i32> [#uses=1]
br label %bb10
bb10: ; preds = %bb18, %bb1
%j.1 = phi i32 [ %indvar.next, %bb1 ], [ 0, %bb18 ] ; <i32>
[#uses=4]
%tmp13 = icmp slt i32 %j.1, %i.0 ; <i1> [#uses=1]
br i1 %tmp13, label %bb1, label %bb15
bb15: ; preds = %bb10
%indvar.next1 = add i32 %i.0, 1 ; <i32> [#uses=1]
br label %bb18
bb18: ; preds = %bb15, %entry
%i.0 = phi i32 [ 0, %entry ], [ %indvar.next1, %bb15 ] ; <i32>
[#uses=5]
%exitcond = icmp ne i32 %i.0, 100 ; <i1> [#uses=1]
br i1 %exitcond, label %bb10, label %return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I was hoping that the exit condition of the inner loop "%tmp13 = icmp slt i32
%j.1, %i.0" would be turned into "%tmp13 = icmp ne i32 %j.1, %i.0".
But this didnt happen.
I didnt use tail duplicate and loop rotate to get the first bitcode (attached
as foo.bc). So my loop is in a bad form?
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list