forked from iden3/circom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
skip body extraction when the loop has 0 iterations (#57)
- Loading branch information
1 parent
d4130d6
commit e6c4f14
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
pragma circom 2.0.0; | ||
|
||
// REQUIRES: circom | ||
// RUN: rm -rf %t && mkdir %t && %circom --llvm -o %t %s | sed -n 's/.*Written successfully:.* \(.*\)/\1/p' | xargs cat | FileCheck %s --enable-var-scope | ||
|
||
template SegmentMulFix(nWindows) { | ||
signal input e[nWindows]; | ||
} | ||
|
||
template EscalarMulFix() { | ||
//Needs at least 2 subcomp to trigger the crash | ||
component segments[2]; | ||
for (var s = 0; s < 2; s++) { | ||
|
||
// s = 0, nseg = 9, nWindows = 9 | ||
// s = 1, nseg = 4, nWindows = 6 | ||
var nseg = (s == 0) ? 9 : 4; | ||
var nWindows = (s == 0) ? 9 : 6; | ||
|
||
segments[s] = SegmentMulFix(nWindows); | ||
|
||
// Needs this split loop to trigger the crash | ||
for (var i = 0; i < nseg; i++) { | ||
//Runs 9 times for s=0 | ||
//Runs 4 times for s=1 | ||
segments[s].e[i] <-- 999; | ||
} | ||
for (var i = nseg; i < nWindows; i++) { | ||
//Runs 0 times for s=0 //this is the case where the extracted body is generated but shouldn't be! | ||
//Runs 2 times for s=1 | ||
segments[s].e[i] <-- 888; | ||
} | ||
} | ||
} | ||
|
||
component main = EscalarMulFix(); | ||
|
||
//CHECK-NOT: ..generated..loop.body. | ||
// | ||
//CHECK-LABEL: define void @EscalarMulFix_2_run([0 x i256]* %0) | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 999 | ||
//CHECK: store i256 888 | ||
//CHECK: store i256 888 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters