LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 47960 - Incorrect transformation of fabs with nnan flag
Summary: Incorrect transformation of fabs with nnan flag
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-23 18:27 PDT by Juneyoung Lee
Modified: 2021-07-25 07:46 PDT (History)
6 users (show)

See Also:
Fixed By Commit(s): 7bd361200a7b


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juneyoung Lee 2020-10-23 18:27:41 PDT
// llvm/test/Transforms/InstCombine/fabs.ll

```
define double @select_fcmp_nnan_ole_zero(double %x) {
%0:
  %lezero = fcmp ole double %x, 0.000000
  %negx = fsub nnan double 0.000000, %x
  %fabs = select i1 %lezero, double %negx, double %x
  ret double %fabs
}
=>
define double @select_fcmp_nnan_ole_zero(double %x) {
%0:
  %1 = fabs nnan double %x
  ret double %1
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source

Example:
double %x = NaN

Source:
i1 %lezero = #x0 (0)
double %negx = poison
double %fabs = NaN

Target:
double %1 = poison
Source value: NaN
Target value: poison
```

After the transformation, nnan flag should be dropped because %x can be NaN.
Comment 1 Sanjay Patel 2021-05-03 05:57:55 PDT
https://reviews.llvm.org/D101727
Comment 2 Sanjay Patel 2021-07-25 07:46:45 PDT
This has potential to cause perf regressions:
https://reviews.llvm.org/rG7bd361200a7b
...but hopefully that makes the transform sound for all existing regression tests.

We discussed follow-ups to improve the transform in the review.