[llvm-bugs] [Bug 37341] New: Missed optimization: optimize unnecessary std::sort

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 4 09:51:00 PDT 2018


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

            Bug ID: 37341
           Summary: Missed optimization: optimize unnecessary std::sort
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zamazan4ik at tut.by
                CC: llvm-bugs at lists.llvm.org

clang trunk with -O3 for code below doesn't optimize std::sort (compiler must
remove it from output binary):


#include <algorithm>
#include <numeric>

void foo(int* a, int size)
{
    std::sort(a, a + size);
}

int bar(int* a, int b)
{
    foo(a, b);
    return std::accumulate(a, a + b, 0);
}


GCC has similar behaviour. Is it possible to optimize 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/20180504/1b6534e5/attachment.html>


More information about the llvm-bugs mailing list