# Compute the 10th element in the catalan sequence, which is given by:
# c0 = 0; c(n+1) = sum(ci * c(n-i) for i = 0..n)
@main(loop_bound: int) {
loop_incr: int = const 1;
loop_counter: int = const 10;
final_output: int = const 0;
.loop_cond:
loop_cond: bool = lt loop_counter loop_bound;
br loop_cond .loop_body .loop_done;
.loop_body:
output: int = call @orig_main loop_counter;
final_output: int = add final_output output;
loop_counter: int = add loop_counter loop_incr;
jmp .loop_cond;
.loop_done:
print final_output;
}
@orig_main(input : int): int {
catn: int = call @catalan input;
ret catn;
}
# Compute the nth term in the catalan sequence
@catalan(n: int):int{
one: int = const 1;
zero: int = const 0;
guard0: bool = eq n zero;
br guard0 .if .else;
.if:
ret one;
.else:
sum: int = id zero;
idx: int = id zero;
n: int = sub n one;
.while:
guard1: bool = le idx n;
.while.body:
n2: int = sub n idx;
v1: int = call @catalan idx;
v2: int = call @catalan n2;
elti: int = mul v1 v2;
sum: int = add sum elti;
idx: int = add idx one;
jmp .while;
.while.end:
ret sum;
}
errors out with
thread 'main' panicked at src/rvsdg/from_cfg.rs:344:13:
No join point for block NodeIndex(0)
And the following code
# ARGS: 18
# Compute the 10th element in the catalan sequence, which is given by:
# c0 = 0; c(n+1) = sum(ci * c(n-i) for i = 0..n)
@main(loop_bound: int) {
catn: int = call @catalan loop_bound;
print catn;
}
@orig_main(input : int): int {
catn: int = call @catalan input;
ret catn;
}
# Compute the nth term in the catalan sequence
@catalan(n: int):int{
one: int = const 1;
zero: int = const 0;
guard0: bool = eq n zero;
br guard0 .if .else;
.if:
# ret one;
.else:
sum: int = id zero;
idx: int = id zero;
n: int = sub n one;
.while.body:
sum: int = call @catalan idx;
idx: int = add idx one;
guard1: bool = le idx n;
br guard1 .while.body .while.end;
.while.end:
ret sum;
}
errors out with
thread 'main' panicked at dag_in_context/src/typechecker.rs:358:17:
assertion `left == right` failed: Expected argument type to be TupleT([IntT, StateT]). Got TupleT([StateT, IntT])
left: TupleT([StateT, IntT])
right: TupleT([IntT, StateT])
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
On
fix-state-passthrough
, the following codeerrors out with
And the following code
errors out with