Skip to content

[InstCombine] Miscompilation select (fcmp nsz olt X, 0.0), -0.0, X -> select (fcmp nsz ole X, -0.0), -0.0, X #141017

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

Open
dtcxzyw opened this issue May 22, 2025 · 0 comments
Assignees

Comments

@dtcxzyw
Copy link
Member

dtcxzyw commented May 22, 2025

Reproducer: https://alive2.llvm.org/ce/z/Uydp8F

define float @src(float %x) {
  %cmp = fcmp nsz olt float %x, 0.0
  %sel = select i1 %cmp, float -0.0, float %x
  ret float %sel
}

define float @tgt(float %x) {
  %.inv = fcmp nsz ole float %x, -0.000000e+00
  %sel1 = select i1 %.inv, float -0.000000e+00, float %x
  ret float %sel1
}
Transformation doesn't verify!

ERROR: Target's return value is more undefined

Example:
float %x = #x00000000 (+0.0)

Source:
i1 %cmp = #x0 (0)
float %sel = #x00000000 (+0.0)

Target:
i1 %.inv = #x1 (1)
float %sel1 = #x00000000 (+0.0)
Source value: #x00000000 (+0.0)
Target value: #x00000000 (+0.0)
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

1 participant