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

InstCombine: fold of shuffle into fadd changes NaN payload #74326

Closed
nunoplopes opened this issue Dec 4, 2023 · 1 comment
Closed

InstCombine: fold of shuffle into fadd changes NaN payload #74326

nunoplopes opened this issue Dec 4, 2023 · 1 comment

Comments

@nunoplopes
Copy link
Member

This optimization changes the NaN payload. Originally it was a pass-through for the last 2 elements, while the optimized code can produce more NaN payloads.

; llvm/test/Transforms/InstCombine/shuffle_select-inseltpoison.ll

define <4 x float> @fadd(<4 x float> %v) {
  %b = fadd <4 x float> %v, { 41.000000, 42.000000, 43.000000, 44.000000 }
  %s = shufflevector <4 x float> %b, <4 x float> %v, 0, 1, 6, 7
  ret <4 x float> %s
}
=>
define <4 x float> @fadd(<4 x float> %v) {
  %s = fadd <4 x float> %v, { 41.000000, 42.000000, -0.000000, -0.000000 }
  ret <4 x float> %s
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
<4 x float> %v = < #xff800400 (SNaN), #x00000000 (+0.0), #x7f804000 (SNaN), #x00000000 (+0.0) >

Source:
<4 x float> %b = < #x7f800400 (SNaN), #x42280000 (42), #x7f804000 (SNaN), #x42300000 (44) >
<4 x float> %s = < #x7f800400 (SNaN), #x42280000 (42), #x7f804000 (SNaN), #x00000000 (+0.0) >

Target:
<4 x float> %s = < #xff800400 (SNaN), #x42280000 (42), #xff804000 (SNaN), #x00000000 (+0.0) >
Source value: < #x7f800400 (SNaN), #x42280000 (42), #x7f804000 (SNaN), #x00000000 (+0.0) >
Target value: < #xff800400 (SNaN), #x42280000 (42), #xff804000 (SNaN), #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