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

CSE optimization confuses -0.0 with 0.0 #7042

Closed
vicuna opened this issue Nov 15, 2015 · 2 comments
Closed

CSE optimization confuses -0.0 with 0.0 #7042

vicuna opened this issue Nov 15, 2015 · 2 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Nov 15, 2015

Original bug ID: 7042
Reporter: @xavierleroy
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2017-02-16T14:16:46Z)
Resolution: fixed
Priority: normal
Severity: major
Platform: x86-64
Version: 4.03.0+dev / +beta1
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: back end (clambda to assembly)
Related to: #6442

Bug description

Owing to the use of Pervasives.compare, the new CSE pass of 4.03 considers as equal the instructions "Iconst_float 0.0" and "Iconst_float (-0.0)", replacing the latter by a move of the result of the former. This is not correct, as demonstrated by the attached repro case.

Possible fixes:

  • use a specific comparison function, as done for Incorrect propagation of -0. #6442
  • at some point in the back-end (C--? Mach?), use int64 instead of float to represent FP constants.

Steps to reproduce

Compile mzero.ml using ocamlc and using ocamlopt, then compare the outputs.

File attachments

@vicuna
Copy link
Author

vicuna commented Nov 17, 2015

Comment author: @mshinwell

I think Flambda may suffer from a similar problem; in fact, we already have a code review comment about it. Maybe we should consider a different representation for floats even before Cmm.

https://github.com/chambart/ocaml-1/blob/flambda_trunk/middle_end/simplify_common.mli

@vicuna
Copy link
Author

vicuna commented Nov 19, 2015

Comment author: @xavierleroy

Fixed by commit [trunk 6cd8656].

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

2 participants