[llvm-bugs] [Bug 47943] New: Incorrect fabs optimization when fdiv or fmul is involved

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 22 04:30:53 PDT 2020


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

            Bug ID: 47943
           Summary: Incorrect fabs optimization when fdiv or fmul is
                    involved
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: juneyoung.lee at sf.snu.ac.kr
                CC: llvm-bugs at lists.llvm.org

----------------------------------------
// Transforms/InstCombine/fmul.ll

define float @fabs_squared(float %x) {
%0:
  %x.fabs = fabs float %x
  %mul = fmul float %x.fabs, %x.fabs
  ret float %mul 
}
=>
define float @fabs_squared(float %x) {
%0:
  %mul = fmul float %x, %x
  ret float %mul 
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
float %x = undef

Source:
float %x.fabs = NaN [based on undef value]
float %mul = NaN  [based on undef value]

Target:
float %mul = #x80000000 (-0.0)
Source value: NaN
Target value: #x80000000 (-0.0)

----------------------------------------
// Transforms/InstCombine/fdiv.ll

define float @fabs_same_op(float %x) {
%0:
  %a = fabs float %x
  %r = fdiv float %a, %a
  ret float %r
}
=>
define float @fabs_same_op(float %x) {
%0:
  %r = fdiv float %x, %x
  ret float %r
}
Transformation doesn't verify!
ERROR: Value mismatch
----------------------------------------

After optimization, `fmul %x, %x` isn't guaranteed to be non-negative because
the result can be negative if %x was undef.
Similarly for the `fdiv` case.

-- 
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/20201022/4de8d5bf/attachment-0001.html>


More information about the llvm-bugs mailing list