[llvm-bugs] [Bug 34775] New: Different unrolling behavior with manual hoisting

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 28 22:25:40 PDT 2017


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

            Bug ID: 34775
           Summary: Different unrolling behavior with manual hoisting
           Product: tools
           Version: 5.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: opt
          Assignee: unassignedbugs at nondot.org
          Reporter: piotr.padlewski at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hey,
I am not sure if this is a bug or it is by design, but I recently found out
that
clang unrolls these two loops in different way:

#include <vector>

void bar(std::vector<int> &v, int* p) {
  auto size = v.size();
  for (int i = 0 ; i < size; i++)
    p[i] = v[i];
}

void bar2(std::vector<int> &v, int* p) {
  for (int i = 0 ; i < v.size(); i++)
    p[i] = v[i];
}

https://godbolt.org/g/U1kH8P

I would probably guess that LICM hoists the size after the unrolling, but I
haven't checked that and also have no idea which one is faster. It is just
weird to me that we were able to hoist v.size() in the bar2, but did not
perform the same unrolling.

-- 
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/20170929/0731ae8c/attachment.html>


More information about the llvm-bugs mailing list