Issue 179613
Summary [InstCombine] Dropping `fabs` around `fmul (fabs nnan x)`, `+inf` changes `NaN` sign for `x=+0.0`
Labels new issue
Assignees
Reporter ariskeirio
    **Description**

I observed a transformation involving `fabs` and `fmul` with `+inf` that cannot verify under Alive2 due to a **NaN payload mismatch**, even though both sides evaluate to NaN.https://alive2.llvm.org/ce/z/7yBXf4

**Input Program**

**Source**

```llvm
define float @src(float %x) {
  %fabs.x = call nnan float @llvm.fabs.f32(float %x)
  %mul.fabs.x = fmul float %fabs.x, 0x7FF0000000000000
  %x.is.zero = fcmp oeq float %x, 0.000000e+00
 %2 = call float @llvm.fabs.f32(float %mul.fabs.x)
  %select = select i1 %x.is.zero, float %2, float %fabs.x
  ret float %select
}
```

This is transformed to:
**Target**

```llvm
define float @tgt(float %x) {
 %fabs.x = call nnan float @llvm.fabs.f32(float %x)
  %mul.fabs.x = fmul float %fabs.x, 0x7FF0000000000000
  %x.is.zero = fcmp oeq float %x, 0.000000e+00
  %select = select i1 %x.is.zero, float %mul.fabs.x, float %fabs.x
  ret float %select
}
```


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to