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

Implement f64.promote_f32 instruction #457

Merged
merged 2 commits into from
Aug 12, 2020
Merged

Implement f64.promote_f32 instruction #457

merged 2 commits into from
Aug 12, 2020

Conversation

chfast
Copy link
Collaborator

@chfast chfast commented Aug 4, 2020

image

This is rather straight forward as conversion f32 to f64 is lossless. The only fancy checks are for NaN values. Canonical NaN must be converted to canonical one, and any other NaN must be converted to any arithmetic NaN.

https://webassembly.github.io/spec/core/exec/numerics.html#op-promote

@chfast chfast force-pushed the fp_convert branch 2 times, most recently from bd3ae4a to e5a3d18 Compare August 8, 2020 07:04
@chfast chfast force-pushed the fp_promote branch 2 times, most recently from 128ebd3 to d677203 Compare August 9, 2020 20:21
{-FP32::Limits::infinity(), -FP64::Limits::infinity()},

// The canonical NaN must result in canonical NaN (only the top bit set).
{FP32::nan(FP32::canon), FP64::nan(FP64::canon)},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add -FP32::nan(FP32::canon) case

Copy link
Member

Choose a reason for hiding this comment

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

And anan cases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add -FP32::nan(FP32::canon) case

Added.

And anan cases?

Outside of the loop as they require sophisticated checks.

@chfast chfast force-pushed the fp_convert branch 2 times, most recently from 850f0d5 to 89cd563 Compare August 11, 2020 16:10
lib/fizzy/execute.cpp Outdated Show resolved Hide resolved
Base automatically changed from fp_convert to master August 11, 2020 22:07
@chfast chfast force-pushed the fp_promote branch 3 times, most recently from 6faf11b to 4fe85a3 Compare August 12, 2020 07:49
@codecov
Copy link

codecov bot commented Aug 12, 2020

Codecov Report

Merging #457 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #457   +/-   ##
=======================================
  Coverage   99.53%   99.53%           
=======================================
  Files          54       54           
  Lines       16015    16075   +60     
=======================================
+ Hits        15941    16001   +60     
  Misses         74       74           

// An arithmetic NaN must result in any arithmetic NaN (payload >= canonical payload).
// The spec allows the result to be the canonical NaN, but in the current implementation it
// is not the case and the check is more restrictive than the spec requires.
const auto res1 = execute(*instance, 0, {FP32::nan(FP32::canon + 1)});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add also -FP32::nan(FP32::canon + 1) and -FP32::nan(1) cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@axic axic merged commit 23d6a6a into master Aug 12, 2020
@axic axic deleted the fp_promote branch August 12, 2020 13:51
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.

3 participants