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

Add >=0 constraints to quot_round_zero and rem_round_zero #553

Open
Timmmm opened this issue Sep 20, 2024 · 4 comments
Open

Add >=0 constraints to quot_round_zero and rem_round_zero #553

Timmmm opened this issue Sep 20, 2024 · 4 comments

Comments

@Timmmm
Copy link
Collaborator

Timmmm commented Sep 20, 2024

The type declarations for those division operators are missing >0 and >=0 constraints.

See https://github.com/riscv/sail-riscv/pull/552/files#r1768223964

@Alasdair
Copy link
Collaborator

I had a go at doing this. It should be possible, but there are a few places where we will need to add explicit asserts for divisors, even if it looks somewhat obvious:

  if EMUL_pow < 0 then nf / (2 ^ (0 - EMUL_pow)) <= 8

This is never division by zero, but it requires reasoning about non-linear arithmetic to prove it which the SMT solver can't do.

@Timmmm
Copy link
Collaborator Author

Timmmm commented Sep 20, 2024

Hmm isn't the output of 2 ^ always greater than zero? That does feel obvious...

@Alasdair
Copy link
Collaborator

Yes, but in practice the SMT solver just gives up whenever it sees 2 ^ n and n isn't bounded. I have a fallback routine that replaces 2 ^ with an arbitrary function that is equivalent up to 2 ^ 64 so I can check any problem that is unsatisfiable for such a function must be unsatisfiable in general, and I could improve that fallback to handle this case but it doesn't work without an explicit assert right now.

@Alasdair
Copy link
Collaborator

That does mean the other solution is to really understand the vector spec and add tight bounds to every variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants