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
InstSimplify: fadd (nsz op), +0 incorrectly removed #45123
Comments
Should we clarify the behavior of 'nsz'? From LangRef: If we make that like "nnan" or "ninf": I'm not sure what the implications of that change would be. If we keep the current definition that uses "insignificant", is there a way to say that -0.0 is an alias bit-value for +0.0 in Alive2? |
LangRef is a bit vague indeed. What Alive2 implements is that if the input or output is -0 or +0, then it is changed to be a non-deterministic choice of +/- 0.
Uhm, not sure we could use that nsz for clang's -ffast-math then. It feels a bit extreme to give poison for e.g. |
Right - just wanted to decide where to make the logic fix. Proposal: |
Extended Description
Test: Transforms/InstSimplify/fast-math.ll
Summary: +0 + +0 == +0 and -0 + +0 == +0 in default rounding mode. Hence below when %nsz is +/-0 the function returns +0 only, while the optimized function returns +/-0.
define float @fold_fadd_cannot_be_neg0_nsz_src_x_0(float %a, float %b) {
%nsz = fmul nsz float %a, %b
%add = fadd float %nsz, 0.000000
ret float %add
}
=>
define float @fold_fadd_cannot_be_neg0_nsz_src_x_0(float %a, float %b) {
%nsz = fmul nsz float %a, %b
ret float %nsz
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
float %a = #x01e21080 (0.000000000000?)
float %b = #x00225d01 (0.000000000000?)
Source:
float %nsz = #x80000000 (-0.0)
float %add = #x00000000 (+0.0)
Target:
float %nsz = #x80000000 (-0.0)
Source value: #x00000000 (+0.0)
Target value: #x80000000 (-0.0)
https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=1ede71ade7988ad1&test=Transforms%2FInstSimplify%2Ffast-math.ll
The text was updated successfully, but these errors were encountered: