[llvm-bugs] [Bug 37912] New: Clang-cl inefficient assembly, 'inc' not generated

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 23 05:04:13 PDT 2018


            Bug ID: 37912
           Summary: Clang-cl inefficient assembly, 'inc' not generated
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jvapen at gmail.com
                CC: llvm-bugs at lists.llvm.org

Unfortunately, I am unable to share all details for this.
However in investigating why the generated executable by clang-cl is 10% slower
than the one of MSVC, I did notice the following already when comparing the
generated assembly:

MSVC uses specialized inc/dec instructions while clang uses add instructions:
        MSVC: incq   0x20(%rbx)
        Clang: addq   $0x1,(%rcx)
        MSVC: inc    %rcx
        Clang: add    $0x1,%rdx
        MSVC: dec    %eax
        Clang: add    $0xffffffff,%edi

File was compiled with:
clang-cl.exe -fms-compatibility-version=19.11 /DBOOST_USE_WINDOWS_H
-Weverything -Wno-unused-command-line-argument /nologo /c /W4 /Wall /wd4710
/wd4711 /GR /EHsc /favor:INTEL64 /fp:precise /FS /std:c++17  /Ox /Z7 /MD
/bigobj  t.cpp 

Note that /favor:INTEL64 ain't recognized  by clang, which might be the reason
the inc instruction doesn't get selected.

At the same time, it is remarkable that for most functions, more non-volotile
registers get pushed/popped by clang than by MSVC. In the hot path, I've
noticed 8 pop instructions for clang and 3 for MSVC.

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/20180623/e684ad2e/attachment-0001.html>

More information about the llvm-bugs mailing list