Issue 74326
Summary InstCombine: fold of shuffle into fadd changes NaN payload
Labels miscompilation, llvm:instcombine, floating-point
Assignees
Reporter nunoplopes
    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
; 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) >
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to