Skip to content

Commit

Permalink
Do not extract loops with just 1 iteration to a new function
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hoffman authored Jul 10, 2024
1 parent 38a7a2d commit d73813f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 142 deletions.
22 changes: 13 additions & 9 deletions circom/tests/constraints/arr_cpy_store.circom
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ template Foo(N) {

component main = Foo(2);

//CHECK-LABEL: define{{.*}} void @..generated..loop.body.
//CHECK-SAME: [[$F_ID_1:[0-9]+\.F]]([0 x i256]* %lvars, [0 x i256]* %signals, i256* %subsig_0, [0 x i256]* %sub_0, i256* %subc_0){{.*}} {
//CHECK-NEXT: ..generated..loop.body.[[$F_ID_1]]:
//CHECK-NEXT: br label %store1
//CHECK-EMPTY:
//CHECK-NEXT: store1:
//CHECK-NEXT: %[[DST_PTR:[0-9a-zA-Z_.]+]] = getelementptr i256, i256* %subsig_0, i32 0
//CHECK-NEXT: %[[SRC_PTR:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %signals, i32 0, i32 0
//CHECK-LABEL: define{{.*}} void @Foo_{{[0-9]+}}_run([0 x i256]* %0){{.*}} {
//CHECK: unrolled_loop4:
//CHECK-NEXT: %[[T04:[0-9a-zA-Z_.]+]] = getelementptr [1 x { [0 x i256]*, i32 }], [1 x { [0 x i256]*, i32 }]* %subcmps, i32 0, i32 0, i32 0
//CHECK-NEXT: %[[T05:[0-9a-zA-Z_.]+]] = load [0 x i256]*, [0 x i256]** %[[T04]], align 8
//CHECK-NEXT: %[[DST_PTR:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %[[T05]], i32 0, i32 0
//CHECK-NEXT: %[[SRC_PTR:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %0, i32 0, i32 0
//CHECK-NEXT: %[[COPY_SRC_0:[0-9a-zA-Z_.]+]] = getelementptr i256, i256* %[[SRC_PTR]], i32 0
//CHECK-NEXT: %[[COPY_DST_0:[0-9a-zA-Z_.]+]] = getelementptr i256, i256* %[[DST_PTR]], i32 0
//CHECK-NEXT: %[[COPY_VAL_0:[0-9a-zA-Z_.]+]] = load i256, i256* %[[COPY_SRC_0]], align 4
Expand All @@ -44,4 +42,10 @@ component main = Foo(2);
//CHECK-NEXT: %[[T03:[0-9a-zA-Z_.]+]] = load i256, i256* %[[COPY_DST_1]], align 4
//CHECK-NEXT: %[[CONSTRAINT_3:[0-9a-zA-Z_.]+]] = alloca i1, align 1
//CHECK-NEXT: call void @__constraint_values(i256 %[[COPY_VAL_12]], i256 %[[T03]], i1* %[[CONSTRAINT_3]])
//CHECK-NEXT: br label %store2
//CHECK-NEXT: %[[T10:[0-9a-zA-Z_.]+]] = getelementptr [1 x { [0 x i256]*, i32 }], [1 x { [0 x i256]*, i32 }]* %subcmps, i32 0, i32 0, i32 1
//CHECK-NEXT: %[[T12:[0-9a-zA-Z_.]+]] = load i32, i32* %[[T10]], align 4
//CHECK-NEXT: %[[T13:[0-9a-zA-Z_.]+]] = sub i32 %[[T12]], 2
//CHECK-NEXT: store i32 %[[T13]], i32* %[[T10]], align 4
//CHECK-NEXT: %[[T11:[0-9a-zA-Z_.]+]] = getelementptr [2 x i256], [2 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: store i256 3, i256* %[[T11]], align 4
//CHECK-NEXT: br label %prologue
56 changes: 9 additions & 47 deletions circom/tests/loops/inner_loops.circom
Original file line number Diff line number Diff line change
Expand Up @@ -68,57 +68,19 @@ component main = InnerLoops(2);
//CHECK-NEXT: ret void
//CHECK-NEXT: }
//
//CHECK-LABEL: define{{.*}} void @..generated..loop.body.
//CHECK-SAME: [[$F_ID_1:[0-9]+]]([0 x i256]* %lvars, [0 x i256]* %signals){{.*}} {
//CHECK-NEXT: ..generated..loop.body.[[$F_ID_1]]:
//CHECK-NEXT: br label %store1
//CHECK-EMPTY:
//CHECK-NEXT: store1:
//CHECK-NEXT: %[[T00:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 3
//CHECK-NEXT: %[[T01:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T00]], align 4
//CHECK-NEXT: %[[C01:[0-9a-zA-Z_.]+]] = call i32 @fr_cast_to_addr(i256 %[[T01]])
//CHECK-NEXT: %[[A01:[0-9a-zA-Z_.]+]] = mul i32 1, %[[C01]]
//CHECK-NEXT: %[[A02:[0-9a-zA-Z_.]+]] = add i32 %[[A01]], 1
//CHECK-NEXT: %[[T12:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 %[[A02]]
//CHECK-NEXT: %[[T02:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 3
//CHECK-NEXT: %[[T03:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T02]], align 4
//CHECK-NEXT: %[[C02:[0-9a-zA-Z_.]+]] = call i32 @fr_cast_to_addr(i256 %[[T03]])
//CHECK-NEXT: %mul_addr2 = mul i32 1, %[[C02]]
//CHECK-NEXT: %add_addr3 = add i32 %mul_addr2, 1
//CHECK-NEXT: %[[T04:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 %add_addr3
//CHECK-NEXT: %[[T05:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T04]], align 4
//CHECK-NEXT: %[[T06:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 3
//CHECK-NEXT: %[[T07:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T06]], align 4
//CHECK-NEXT: %[[T08:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 4
//CHECK-NEXT: %[[T09:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T08]], align 4
//CHECK-NEXT: %[[C03:[0-9a-zA-Z_.]+]] = call i256 @fr_sub(i256 %[[T07]], i256 %[[T09]])
//CHECK-NEXT: %[[C04:[0-9a-zA-Z_.]+]] = call i32 @fr_cast_to_addr(i256 %[[C03]])
//CHECK-NEXT: %mul_addr5 = mul i32 1, %[[C04]]
//CHECK-NEXT: %add_addr6 = add i32 %mul_addr5, 0
//CHECK-NEXT: %[[T10:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %signals, i32 0, i32 %add_addr6
//CHECK-NEXT: %[[T11:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T10]], align 4
//CHECK-NEXT: %[[C05:[0-9a-zA-Z_.]+]] = call i256 @fr_add(i256 %[[T05]], i256 %[[T11]])
//CHECK-NEXT: store i256 %[[C05]], i256* %[[T12]], align 4
//CHECK-NEXT: br label %store2
//CHECK-EMPTY:
//CHECK-NEXT: store2:
//CHECK-NEXT: %[[T15:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 4
//CHECK-NEXT: %[[T13:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 4
//CHECK-NEXT: %[[T14:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T13]], align 4
//CHECK-NEXT: %[[C06:[0-9a-zA-Z_.]+]] = call i256 @fr_add(i256 %[[T14]], i256 1)
//CHECK-NEXT: store i256 %[[C06]], i256* %[[T15]], align 4
//CHECK-NEXT: br label %return3
//CHECK-EMPTY:
//CHECK-NEXT: return3:
//CHECK-NEXT: ret void
//CHECK-NEXT: }
//
//CHECK-LABEL: define{{.*}} void @InnerLoops_{{[0-9]+}}_run([0 x i256]* %0){{.*}} {
//CHECK: unrolled_loop{{[0-9]+}}:
//CHECK-NEXT: %[[T05:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 4
//CHECK-NEXT: store i256 0, i256* %[[T05]], align 4
//CHECK-NEXT: %[[T06:[0-9a-zA-Z_.]+]] = bitcast [5 x i256]* %lvars to [0 x i256]*
//CHECK-NEXT: call void @..generated..loop.body.[[$F_ID_1]]([0 x i256]* %[[T06]], [0 x i256]* %0)
//CHECK-NEXT: %[[T21:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: %[[T22:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: %[[T23:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T22]], align 4
//CHECK-NEXT: %[[T24:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %0, i32 0, i32 0
//CHECK-NEXT: %[[T25:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T24]], align 4
//CHECK-NEXT: %[[T26:[0-9a-zA-Z_.]+]] = call i256 @fr_add(i256 %[[T23]], i256 %[[T25]])
//CHECK-NEXT: store i256 %[[T26]], i256* %[[T21]], align 4
//CHECK-NEXT: %[[T27:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 4
//CHECK-NEXT: store i256 1, i256* %[[T27]], align 4
//CHECK-NEXT: %[[T07:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 3
//CHECK-NEXT: store i256 1, i256* %[[T07]], align 4
//CHECK-NEXT: %[[T08:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 4
Expand Down
29 changes: 6 additions & 23 deletions circom/tests/loops/inner_loops2.circom
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,14 @@ component main = InnerLoops(5);
//CHECK-NEXT: ret void
//CHECK-NEXT: }
//
//CHECK-LABEL: define{{.*}} void @..generated..loop.body.
//CHECK-SAME: [[$F_ID_1:[0-9]+]]([0 x i256]* %lvars, [0 x i256]* %signals){{.*}} {
//CHECK-NEXT: ..generated..loop.body.[[$F_ID_1]]:
//CHECK-NEXT: br label %store{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: store{{[0-9]+}}:
//CHECK-NEXT: %[[T02:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: %[[T00:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %signals, i32 0, i32 0
//CHECK-NEXT: %[[T01:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T00]], align 4
//CHECK-NEXT: store i256 %[[T01]], i256* %[[T02]], align 4
//CHECK-NEXT: br label %store{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: store{{[0-9]+}}:
//CHECK-NEXT: %[[T03:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 7
//CHECK-NEXT: store i256 1, i256* %[[T03]], align 4
//CHECK-NEXT: br label %return{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: return{{[0-9]+}}:
//CHECK-NEXT: ret void
//CHECK-NEXT: }
//
//CHECK-LABEL: define{{.*}} void @InnerLoops_{{[0-9]+}}_run([0 x i256]* %0){{.*}} {
//CHECK: unrolled_loop{{[0-9]+}}:
//CHECK-NEXT: %[[T09:[0-9a-zA-Z_.]+]] = bitcast [8 x i256]* %lvars to [0 x i256]*
//CHECK-NEXT: call void @..generated..loop.body.[[$F_ID_1]]([0 x i256]* %[[T09]], [0 x i256]* %0)
//CHECK-NEXT: %[[T01:[0-9a-zA-Z_.]+]] = getelementptr [8 x i256], [8 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: %[[T02:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %0, i32 0, i32 0
//CHECK-NEXT: %[[T03:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T02]], align 4
//CHECK-NEXT: store i256 %[[T03]], i256* %[[T01]], align 4
//CHECK-NEXT: %[[T04:[0-9a-zA-Z_.]+]] = getelementptr [8 x i256], [8 x i256]* %lvars, i32 0, i32 7
//CHECK-NEXT: store i256 1, i256* %[[T04]], align 4
//CHECK-NEXT: br label %store{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: store{{[0-9]+}}:
Expand Down
29 changes: 6 additions & 23 deletions circom/tests/loops/inner_loops3.circom
Original file line number Diff line number Diff line change
Expand Up @@ -121,31 +121,14 @@ component main = InnerLoops(5);
//CHECK-NEXT: ret void
//CHECK-NEXT: }
//
//CHECK-LABEL: define{{.*}} void @..generated..loop.body.
//CHECK-SAME: [[$F_ID_1:[0-9]+]]([0 x i256]* %lvars, [0 x i256]* %signals){{.*}} {
//CHECK-NEXT: ..generated..loop.body.[[$F_ID_1]]:
//CHECK-NEXT: br label %store{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: store{{[0-9]+}}:
//CHECK-NEXT: %[[T02:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: %[[T00:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %signals, i32 0, i32 0
//CHECK-NEXT: %[[T01:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T00]], align 4
//CHECK-NEXT: store i256 %[[T01]], i256* %[[T02]], align 4
//CHECK-NEXT: br label %store{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: store{{[0-9]+}}:
//CHECK-NEXT: %[[T03:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 6
//CHECK-NEXT: store i256 1, i256* %[[T03]], align 4
//CHECK-NEXT: br label %return{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: return{{[0-9]+}}:
//CHECK-NEXT: ret void
//CHECK-NEXT: }
//
//CHECK-LABEL: define{{.*}} void @InnerLoops_{{[0-9]+}}_run([0 x i256]* %0){{.*}} {
//CHECK: unrolled_loop{{[0-9]+}}:
//CHECK-NEXT: %[[T08:[0-9a-zA-Z_.]+]] = bitcast [7 x i256]* %lvars to [0 x i256]*
//CHECK-NEXT: call void @..generated..loop.body.[[$F_ID_1]]([0 x i256]* %[[T08]], [0 x i256]* %0)
//CHECK-NEXT: %[[T01:[0-9a-zA-Z_.]+]] = getelementptr [7 x i256], [7 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: %[[T02:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %0, i32 0, i32 0
//CHECK-NEXT: %[[T03:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T02]], align 4
//CHECK-NEXT: store i256 %[[T03]], i256* %[[T01]], align 4
//CHECK-NEXT: %[[T04:[0-9a-zA-Z_.]+]] = getelementptr [7 x i256], [7 x i256]* %lvars, i32 0, i32 6
//CHECK-NEXT: store i256 1, i256* %[[T04]], align 4
//CHECK-NEXT: br label %store{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: store{{[0-9]+}}:
Expand Down
45 changes: 6 additions & 39 deletions circom/tests/loops/inner_loops4.circom
Original file line number Diff line number Diff line change
Expand Up @@ -61,49 +61,16 @@ component main = InnerLoops(2);
//CHECK-NEXT: ret void
//CHECK-NEXT: }
//
//CHECK-LABEL: define{{.*}} void @..generated..loop.body.
//CHECK-SAME: [[$F_ID_1:[0-9]+]]([0 x i256]* %lvars, [0 x i256]* %signals){{.*}} {
//CHECK-NEXT: ..generated..loop.body.[[$F_ID_1]]:
//CHECK-NEXT: br label %store{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: store{{[0-9]+}}:
//CHECK-NEXT: %[[T00:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 4
//CHECK-NEXT: %[[T01:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T00]], align 4
//CHECK-NEXT: %[[C01:[0-9a-zA-Z_.]+]] = call i32 @fr_cast_to_addr(i256 %[[T01]])
//CHECK-NEXT: %[[A01:[0-9a-zA-Z_.]+]] = mul i32 1, %[[C01]]
//CHECK-NEXT: %[[A02:[0-9a-zA-Z_.]+]] = add i32 %[[A01]], 1
//CHECK-NEXT: %[[T08:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 %[[A02]]
//CHECK-NEXT: %[[T02:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 4
//CHECK-NEXT: %[[T03:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T02]], align 4
//CHECK-NEXT: %[[T04:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 3
//CHECK-NEXT: %[[T05:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T04]], align 4
//CHECK-NEXT: %[[C02:[0-9a-zA-Z_.]+]] = call i256 @fr_sub(i256 %[[T03]], i256 %[[T05]])
//CHECK-NEXT: %[[C03:[0-9a-zA-Z_.]+]] = call i32 @fr_cast_to_addr(i256 %[[C02]])
//CHECK-NEXT: %[[A03:[0-9a-zA-Z_.]+]] = mul i32 1, %[[C03]]
//CHECK-NEXT: %[[A04:[0-9a-zA-Z_.]+]] = add i32 %[[A03]], 0
//CHECK-NEXT: %[[T06:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %signals, i32 0, i32 %[[A04]]
//CHECK-NEXT: %[[T07:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T06]], align 4
//CHECK-NEXT: store i256 %[[T07]], i256* %[[T08]], align 4
//CHECK-NEXT: br label %store{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: store{{[0-9]+}}:
//CHECK-NEXT: %[[T11:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 3
//CHECK-NEXT: %[[T09:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 3
//CHECK-NEXT: %[[T10:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T09]], align 4
//CHECK-NEXT: %[[C04:[0-9a-zA-Z_.]+]] = call i256 @fr_add(i256 %[[T10]], i256 1)
//CHECK-NEXT: store i256 %[[C04]], i256* %[[T11]], align 4
//CHECK-NEXT: br label %return{{[0-9]+}}
//CHECK-EMPTY:
//CHECK-NEXT: return{{[0-9]+}}:
//CHECK-NEXT: ret void
//CHECK-NEXT: }
//
//CHECK-LABEL: define{{.*}} void @InnerLoops_{{[0-9]+}}_run([0 x i256]* %0){{.*}} {
//CHECK: unrolled_loop{{[0-9]+}}:
//CHECK-NEXT: %[[T06:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 3
//CHECK-NEXT: store i256 0, i256* %[[T06]], align 4
//CHECK-NEXT: %[[T07:[0-9a-zA-Z_.]+]] = bitcast [5 x i256]* %lvars to [0 x i256]*
//CHECK-NEXT: call void @..generated..loop.body.[[$F_ID_1]]([0 x i256]* %[[T07]], [0 x i256]* %0)
//CHECK-NEXT: %[[T21:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: %[[T22:[0-9a-zA-Z_.]+]] = getelementptr [0 x i256], [0 x i256]* %0, i32 0, i32 0
//CHECK-NEXT: %[[T23:[0-9a-zA-Z_.]+]] = load i256, i256* %[[T22]], align 4
//CHECK-NEXT: store i256 %[[T23]], i256* %[[T21]], align 4
//CHECK-NEXT: %[[T24:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 3
//CHECK-NEXT: store i256 1, i256* %[[T24]], align 4
//CHECK-NEXT: %[[T08:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 4
//CHECK-NEXT: store i256 1, i256* %[[T08]], align 4
//CHECK-NEXT: %[[T09:[0-9a-zA-Z_.]+]] = getelementptr [5 x i256], [5 x i256]* %lvars, i32 0, i32 3
Expand Down
2 changes: 1 addition & 1 deletion circuit_passes/src/passes/loop_unroll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<'d> LoopUnrollPass<'d> {

let num_iter = recorder.get_iter();
let mut block_body = vec![];
if EXTRACT_LOOP_BODY_TO_NEW_FUNC && recorder.is_safe_to_move() && num_iter > 0 {
if EXTRACT_LOOP_BODY_TO_NEW_FUNC && recorder.is_safe_to_move() && num_iter > 1 {
// If the loop body contains more than one instruction, extract it into a
// new function and generate 'num_iter' number of calls to that function.
// Otherwise, just duplicate the body 'num_iter' number of times.
Expand Down

0 comments on commit d73813f

Please sign in to comment.