Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard Canonicalization is invalid #1010

Closed
rachitnigam opened this issue May 26, 2022 · 2 comments · Fixed by #1011
Closed

Guard Canonicalization is invalid #1010

rachitnigam opened this issue May 26, 2022 · 2 comments · Fixed by #1011
Assignees
Labels
C: Calyx Extension or change to the Calyx IL Type: Bug Bug in the implementation

Comments

@rachitnigam
Copy link
Contributor

Consider the following two sets of assignments:

w.in = a.out ? 1'd1;
w.in = b.out ? 1'd1;

and

w.in = a.out;
w.in = b.out;

In the first program, we're saying something like: if a.out or b.out is active, forward 1'd1 to w.in, otherwise forward nothing. In the second program, we're saying unconditionally forward both a.out and b.out to w.in which is an obvious runtime conflict.

The first program can be optimized into:

w.in = a.out | b.out ? 1'd1;

However, the canonicalization pass currently transforms program (1) to (2), altering the semantics. We should disable rewrites of the form a = g ? 1'd1 -> a = g and instead only allow the canonicalizer to perform a = 1'd1 ? b to a = b.

@sampsyo
Copy link
Contributor

sampsyo commented May 27, 2022

It's a good example, and I think it clearly depends on nailing down semantics for undefinedness as suggested in #922… namely, I don't think it's a foregone conclusion that this is always a conflict:

w.in = a.out;
w.in = b.out;

We don't right now, but we could decide that this is perfectly safe if a.out and b.out are never defined simultaneously.

@rachitnigam
Copy link
Contributor Author

Right, in which case we need to revisit the meaning of direct assignments and make sure that compilation and other passes don't change it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Calyx Extension or change to the Calyx IL Type: Bug Bug in the implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants