[llvm-bugs] [Bug 45423] New: Size regression -Os performing loop peeling

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 3 15:17:21 PDT 2020


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

            Bug ID: 45423
           Summary: Size regression -Os performing loop peeling
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: michaeljclark at mac.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

FYI. Clang 10.0.0 appears to be peeling and inlining the first iteration of a
loop into the loop header at -Os, whereas Clang 9.0.0 does not.

#include <vector>

void freq_rescale_4(std::vector<size_t> &F)
{
        for (size_t i = 0, j = F.size(); i < j; i++) {
                F[i] /= 2;
                if (F[i] < 1) {
                        F[i] = 1;
                }
        }
}

# Clang 9.0.0, x86_64, -Os
freq_rescale_4(std::vector<unsigned long, std::allocator<unsigned long> >&):
        mov     rax, qword ptr [rdi]
        mov     rcx, qword ptr [rdi + 8]
        sub     rcx, rax
        je      .LBB0_3
        sar     rcx, 3
        xor     edx, edx
        mov     esi, 1
.LBB0_2:                                # =>This Inner Loop Header: Depth=1
        mov     rdi, qword ptr [rax + 8*rdx]
        shr     rdi
        cmove   rdi, rsi
        mov     qword ptr [rax + 8*rdx], rdi
        add     rdx, rsi
        cmp     rdx, rcx
        jb      .LBB0_2
.LBB0_3:
        ret

# Clang 10.0.0, x86_64, -Os
freq_rescale_4(std::vector<unsigned long, std::allocator<unsigned long> >&):)
        mov     rdx, qword ptr [rdi]
        mov     rax, qword ptr [rdi + 8]
        sub     rax, rdx
        je      .LBB0_4
        sar     rax, 3
        mov     rsi, qword ptr [rdx]
        shr     rsi
        mov     r8d, 1
        cmove   rsi, r8
        mov     qword ptr [rdx], rsi
        cmp     rax, 2
        jb      .LBB0_4
        mov     edx, 1
.LBB0_3:                                # =>This Inner Loop Header: Depth=1
        mov     rsi, qword ptr [rdi]
        mov     rcx, qword ptr [rsi + 8*rdx]
        shr     rcx
        cmove   rcx, r8
        mov     qword ptr [rsi + 8*rdx], rcx
        inc     rdx
        cmp     rdx, rax
        jb      .LBB0_3
.LBB0_4:
        ret

-- 
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/20200403/6ee38099/attachment-0001.html>


More information about the llvm-bugs mailing list