cucapra/dahlia

`split` views not lowered correctly

rachitnigam opened this issue · 0 comments

The following program type checks and generates the expected output with the C++ backend:

decl out: ubit<32>[1];

let A: ubit<32>[4 bank 2];
split A_sp = A[by 2];

for (let i: ubit<3> = 0..2) {
  for (let j: ubit<3> = 0..2) unroll 2 {
    let t = A_sp[j][i];
  } combine {
    out[0] += t;
  }
}

However, with --lower, we get the cryptic error:

% ./fuse split.fuse --lower
[Type error] [Line 4, Column 14] `A' is not bound in scope.
split A_sp = A[by 2];

Using --pass-debug, we can see that Lower for loops doesn't handle split views:

...
let A0: ubit<32>[2];
let A1: ubit<32>[2];
split A_sp = A[by 2]; // <-- oops
...

It rewrites A to A0 and A1 but doesn't change the instances of A in the split view.