Skip to content

Add support for atomic_min* and atomic_umin* intrinsics - #1212

Merged
danielsn merged 8 commits into
model-checking:mainfrom
adpaco:atomic-min
May 26, 2022
Merged

danielsn merged 8 commits into
model-checking:mainfrom
adpaco:atomic-min

Conversation

@adpaco

@adpaco adpaco commented May 23, 2022

Copy link
Copy Markdown
Contributor

Description of changes:

Defines a min expression on top of other expressions. Then uses the min expression to add support for atomic_min* and atomic_umin* intrinsics.

Resolved issues:

Part of #1163

Testing:

  • How is this change tested? Removes 10 tests and adds 2.

  • Is this a refactor change? No.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@adpaco
adpaco requested a review from a team as a code owner May 23, 2022 21:55
// Expressions defined on top of other expressions

/// `min(self, e)`
pub fn min(self, e: Expr) -> Expr {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If there are side effects, this will evaluate them twice

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please take a look at the new changes, which complete the definition for is_side_effect and assert that neither of these cause side effects.

@adpaco
adpaco requested a review from danielsn May 25, 2022 22:15
Comment on lines +290 to +297
fn are_side_effect(exprs: &Vec<Expr>) -> bool {
for expr in exprs {
if expr.is_side_effect() {
return true;
}
}
false
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Style ⛏️ : you could use exprs.iter().any(|e| e.is_side_effect())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks!


#[kani::proof]
fn main() {
let mut a1 = 1 as u8;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a reason we only test for u8? Could we make this take a <T> and then test multiple bitwidths?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's pending in #25. But I'd like to do it once all atomic tests are in.

@danielsn
danielsn merged commit fb03ccb into model-checking:main May 26, 2022
@adpaco adpaco mentioned this pull request Jun 14, 2022
42 of 77 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants