[llvm-bugs] [Bug 43724] New: Code generated by clang-9 runs slower than those with previous versions (clang-8/clang-7).

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 19 17:18:43 PDT 2019


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

            Bug ID: 43724
           Summary: Code generated by clang-9 runs slower than those with
                    previous versions (clang-8/clang-7).
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: wuxb45 at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Performance regression observed after upgraded to clang-9 on Archlinux
x86_64/Broadwell (all packages are up-to-date).

The regression has been bisected to the scope of a rwlock implementation with
c11 atomic operations. Code that can reproduce the regression on my a few
Broadwell servers can be found here: https://github.com/wuxb45/atomictest

The most apparent difference is that clang-9 generates "lock incl" for +1
operations and "lock xadd" for +n operations. clang-8 and clang-7 all generate
"lock addl".

The rest of the assembly looks similar but still show some differences on the
ordering of some if-else blocks (just a few places). It is possible that the
branch-prediction are unluckily affected by the changed layout. However, the
code in the above link is excerpted from a larger code base after the
regression was observed. Both versions of the code shows the same behavior and
I still believe it's not _sustainable_ trying to mitigate this issue by
reordering some source code.


The regression has been consistently observed on Xeon E5 2697A v4 (HT off,
broadwell) and Xeon Gold 5120 (HT on, skylake). I have not tried it on other
CPUs.

More details are provided in that github link. Besides, I'm willing to move
some texts here or provide anything else that could be useful.


Appreciate it.

-- 
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/20191020/db0907ca/attachment.html>


More information about the llvm-bugs mailing list