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

On f32/f64.rem #1133

Open
dcodeIO opened this issue Sep 28, 2017 · 4 comments
Open

On f32/f64.rem #1133

dcodeIO opened this issue Sep 28, 2017 · 4 comments

Comments

@dcodeIO
Copy link

dcodeIO commented Sep 28, 2017

I know these are not real instructions, but while implementing a compiler that is not C/C++-based it turned out to be a nuisance. Duplicating fmod every time doesn't seem right to me when embedders could easily provide their anyway ubiquitous implementation.

Could it be re-considered for binary size / peace of mind / alignment with other web-things?

@binji
Copy link
Member

binji commented Sep 28, 2017

WebAssembly typically doesn't provide numeric instructions for operations that aren't commonly available on hardware. That's why there isn't a f32.sin or f32.cos either, though they would probably be useful. Perhaps musl's implementation would be of use: https://github.com/bpowers/musl/blob/master/src/math/fmod.c

@dcodeIO
Copy link
Author

dcodeIO commented Sep 29, 2017

That's about what I am doing currently, yeah. I totally understand the exclusion of sin and cos because these can be implemented in various ways yielding more or less precise results depending on requirements.

The absense of f32/f64.rem however creates a situation where a supposedly exact operation, that is widely supported among other web-platform things (here: JS) as an operator, has to be bundled over and over again, even though the embedder could easily provide it. It's the (perceived unnecessary, despite technical arguments) redundancy this introduces that doesn't seem right to me.

@binji
Copy link
Member

binji commented Sep 29, 2017

Well, if you're interested in championing the feature, I'd suggest presenting a proposal with some data at the next CG meeting. That's coming up pretty soon, but even something preliminary may be worthwhile to get some feedback on how to move forward.

@vmukhachev
Copy link

vmukhachev commented Dec 6, 2021

can be implemented using fma, for some values:

fma(trunc(x / y), -y, x)

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

No branches or pull requests

4 participants