[llvm-bugs] [Bug 49654] New: [InstCombine] Incorrect propagation of nsz from fneg to fdiv

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 19 11:05:31 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49654

            Bug ID: 49654
           Summary: [InstCombine] Incorrect propagation of nsz from fneg
                    to fdiv
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: nunoplopes at sapo.pt
                CC: cameron.mcinally at nyu.edu, juneyoung.lee at sf.snu.ac.kr,
                    llvm-bugs at lists.llvm.org, spatel+llvm at rotateright.com

This is from Transforms/InstCombine/fneg.ll, reduced from fast to just nsz.
The issue is that the original fdiv has no nsz but the optimized one has. In
this case, nsz can be propagated, but not added (even if fneg is nsz).


define float @fdiv_op0_constant_fneg_fmf(float %x) {
  %d = fdiv float 42.000000, %x
  %r = fneg nsz float %d
  ret float %r
}
=>
define float @fdiv_op0_constant_fneg_fmf(float %x) {
  %r = fdiv nsz float -42.000000, %x
  ret float %r
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
float %x = #x80000000 (-0.0)

Source:
float %d = #xff800000 (-oo)
float %r = #x7f800000 (+oo)

Target:
float %r = #xff800000 (-oo)
Source value: #x7f800000 (+oo)
Target value: #xff800000 (-oo)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210319/6da7bd5d/attachment-0001.html>


More information about the llvm-bugs mailing list