[llvm-bugs] [Bug 40040] New: trivial static loop is not eliminated with -Os

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 16 03:58:19 PST 2018


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

            Bug ID: 40040
           Summary: trivial static loop is not eliminated with -Os
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: trass3r at gmail.com
                CC: llvm-bugs at lists.llvm.org

void foo(int* a)
{
        for (int i = 0; i < 8; ++i)
                a[i] = 1;
}

$ clang -Os -march=haswell

        xor     eax, eax
        vbroadcastss    ymm0, dword ptr [rip + .LCPI0_0] # ymm0 =
[1,1,1,1,1,1,1,1]
        mov     ecx, 8
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
        vmovups ymmword ptr [rdi + 4*rax], ymm0
        add     rax, 8
        cmp     rax, rcx
        jne     .LBB0_1

https://godbolt.org/z/Q2Se1r

It also happens with -O2 -fno-unroll-loops and -Os -funroll-loops.
You can also change the loop body, e.g. ++a[i].

-- 
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/20181216/6694af48/attachment.html>


More information about the llvm-bugs mailing list