[llvm-bugs] [Bug 45554] New: Suboptimal optmisation of inlined function loop for AArch64 O3 with LTO

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 15 07:27:38 PDT 2020


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

            Bug ID: 45554
           Summary: Suboptimal optmisation of inlined function loop for
                    AArch64 O3 with LTO
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: david.spickett at linaro.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 23363
  --> https://bugs.llvm.org/attachment.cgi?id=23363&action=edit
Preprocessed source

After https://reviews.llvm.org/D76792 Spec benchmark "xalancbmk" showed
regressions at -O2/-O3 with LTO enabled.

This has been narrowed down to a loop in XalanDOMStringCache::release. Where
extra instructions are inserted in the loop body, that would normally be placed
at the exit points of the function.

For example, before we had:
244         ldur   x10, [x20, #-8]
               cmp    x10, x1 
             ↓ b.eq   e8
<...>
         e8:   sub    x20, x20, #0x8
         ec:   cmp    x20, x8 

After:
   247         mov    x10, x20
    46         ldr    x11, [x10, #8]!
               cmp    x11, x1 
             ↓ b.eq   dc
<...>
         dc:   mov    x20, x10
               cmp    x20, x8 
             ↓ b.ne   f8      

Note that after is using writeback to update x10, and resets it if branch not
taken. This is adding instructions to the loop body, where before we would only
write to x20 if the branch was taken.

I will attach the perf output for before and after, along with the preprocessed
source file. Compile with:
./clang++ -O3 -flto --target=aarch64-linux-gnu
/tmp/perfstuff/XalanDOMStringCache.ii

You'll need a sysroot to do so, which is why I'm trying to make a reduced
example. Having trouble getting that setup though. I think forcing std::find to
be inlined might be enough.

-- 
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/20200415/b2ed4f20/attachment.html>


More information about the llvm-bugs mailing list