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

Vector: Remove now unnecessary uses of undefined #552

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

Alasdair
Copy link
Collaborator

@Alasdair Alasdair commented Sep 20, 2024

A few refactorings to the vector extension:

  • Sail 0.18 contains the vector_init primitive, to make initialising vectors with defined values easier. We can use this in some places where the vector code was creating an uninitialised vector, only to then initialise it later.

  • Second, we can remove some uses of undefined by refactoring slightly how init_masked_result is used, which has the added benefit of making the mask immutable.

  • Sail's pattern completeness checker is now smarter than before, so some wildcard cases in matches can also be safely removed without causing any warnings.

  • We can also remove some asserts by adding an overload for the default division operator for the positive cases where truncating division and the SMT solver's euclidian division are the same, so the type system can just infer the facts those assertions were guaranteeing.

One thing I noticed is the read_vmask_carry function doesn't seem to be doing anything, as it looks like it is only called with vm=0b0 where it is then the same as read_vmask. I didn't make any changes to this in this PR however.

Sail 0.18 contains the vector_init primitive, to make initialising
vectors with defined values easier. We can use this in some places
where the vector code was creating an uninitalised vector, only to
then initialize it later.

Second, we can remove some uses of undefined by refactoring slightly
how init_masked_result is used, which has the added benefit of making
mask immutable.

Some additional constraints need to be added to use the vector_init
primitive.

Sail's pattern completeness checker is now smarter than before, so
some wildcard cases can also be safely removed.
Copy link

Test Results

396 tests  ±0   396 ✅ ±0   0s ⏱️ ±0s
  4 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit f139c0d. ± Comparison against base commit bdf95b0.

Copy link
Collaborator

@Timmmm Timmmm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks!

model/prelude.sail Show resolved Hide resolved
model/riscv_insts_vext_utils.sail Show resolved Hide resolved
model/riscv_vext_regs.sail Show resolved Hide resolved
@Timmmm Timmmm merged commit 6dd6464 into riscv:master Sep 20, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants