Skip to content

Tests for "absolute" intrinsics#1033

Merged
adpaco-aws merged 2 commits intomodel-checking:mainfrom
adpaco-aws:fabsfxx-audit
Apr 13, 2022
Merged

Tests for "absolute" intrinsics#1033
adpaco-aws merged 2 commits intomodel-checking:mainfrom
adpaco-aws:fabsfxx-audit

Conversation

@adpaco-aws
Copy link
Contributor

Description of changes:

The implementation of "absolute" intrinsics (fabsf32 and fabsf64) relies on CBMC's fabsf and fabs. This PR adds tests for them.

Resolved issues:

Part of #727

Call-outs:

Testing:

  • How is this change tested? Adds two tests.

  • 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-aws adpaco-aws requested a review from a team as a code owner April 11, 2022 21:18
kani::assume(!x.is_nan());
let abs_x = unsafe { std::intrinsics::fabsf32(x) };
if x < 0.0 {
assert!(-x == abs_x);
Copy link
Contributor

Choose a reason for hiding this comment

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

At first I was surprised that this was == and not diff < epsilon but I see that floating point has an explicit sign bit https://en.wikipedia.org/wiki/Floating-point_arithmetic#IEEE_754:_floating_point_in_modern_computers

@adpaco-aws adpaco-aws merged commit feaada4 into model-checking:main Apr 13, 2022
@adpaco-aws adpaco-aws mentioned this pull request Apr 13, 2022
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 26, 2022
tedinski pushed a commit that referenced this pull request Apr 27, 2022
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