[llvm-bugs] [Bug 40539] New: [X86] PostRAScheduler can reorder inline assembly containing x87 instructions with other x87 instructions used to get the results from the inline assembly.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 30 12:35:04 PST 2019


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

            Bug ID: 40539
           Summary: [X86] PostRAScheduler can reorder inline assembly
                    containing x87 instructions with other x87
                    instructions used to get the results from the inline
                    assembly.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: craig.topper at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

This test case when compiled with -mtriple=i686 -mcpu=pentium4

@f1 = global float 1.000000e+00, align 4

define zeroext i1 @_Z9test_log2v() {
entry:
  %0 = load float, float* @f1, align 4
  %1 = fpext float %0 to x86_fp80
  %2 = tail call x86_fp80 asm "fld1; fxch; fyl2x",
"={st},0,~{st(1)},~{dirflag},~{fpsr},~{flags}"(x86_fp80 %1)
  %conv = fptrunc x86_fp80 %2 to float
  %3 = fcmp oeq float %conv, 0.000000e+00
  ret i1 %3
}

Will generate this assembly


        pushl   %eax
        .cfi_def_cfa_offset 8
        flds    f1
        fstps   (%esp)
        xorps   %xmm0, %xmm0
        #APP
        fld1
        fxch    %st(1)
        fyl2x
        #NO_APP
        cmpeqss (%esp), %xmm0
        movd    %xmm0, %eax
        andl    $1, %eax
                                        # kill: def $al killed $al killed $eax
        popl    %ecx
        .cfi_def_cfa_offset 4
        retl


The fstps instruction needs to be below the inline assembly block. It's
supposed to store the results from the inline assembly.

-- 
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/20190130/62351167/attachment.html>


More information about the llvm-bugs mailing list