[llvm-bugs] [Bug 49080] New: Incorrect swap of fptrunc with fast-math instructions

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 7 12:30:30 PST 2021


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

            Bug ID: 49080
           Summary: Incorrect swap of fptrunc with fast-math instructions
           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: lebedev.ri at gmail.com, llvm-bugs at lists.llvm.org,
                    Matthew.Arsenault at amd.com, regehr at cs.utah.edu,
                    spatel+llvm at rotateright.com

See the example below where fptrunc & fabs are swapped. The issue is that fabs
has the nninf tag, which becomes poison because its input is inf.

Two solutions come to mind: drop nninf from fabs in the solution, or add
fast-math flags to fptrunc.


define half @test_shrink_intrin_fabs_fast_double_src(float %D) {
  %E = fabs fast float %D
  %F = fptrunc float %E to half
  ret half %F
}
=>
define half @test_shrink_intrin_fabs_fast_double_src(float %D) {
  %1 = fptrunc float %D to half
  %F = fabs fast half %1
  ret half %F
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source

Example:
float %D = #x477ff080 (65520.5)

Source:
float %E = #x477ff080 (65520.5)
half %F = #x7c00 (+oo)

Target:
half %1 = #x7c00 (+oo)
half %F = poison
Source value: #x7c00 (+oo)
Target value: poison


File: llvm/test/Transforms/InstCombine/double-float-shrink-2.ll
A similar test also fails in Transforms/InstCombine/fpcast.ll (test4-fast)

-- 
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/20210207/036e20fd/attachment.html>


More information about the llvm-bugs mailing list