[LLVMbugs] [Bug 23217] New: Inefficient unrolling in vectorization pass when VF==1

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 13 13:53:43 PDT 2015


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

            Bug ID: 23217
           Summary: Inefficient unrolling in vectorization pass when VF==1
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: wmi at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 14199
  --> https://llvm.org/bugs/attachment.cgi?id=14199&action=edit
bad.s

We found the unrolling in loop vectorization pass when VF==1 was inefficient
when analyzing an internal benchmark. The simple testcase 1.c here is used to
show the problem:

1.c:
int a[1000], N;

void foo() {
  long i;
  for (i = 0; i < N; i++) {
    a[i*7] = 3;
  }
}

~/workarea/llvm-r234389/build/bin/clang -O2 -S 1.c

In loop vectorization pass, VF=1 and UF=2 are computed for the above loop.
Because VF==1, no vectorization will be done, but the loop will still be
unrolled by a factor of two. A remainder loop will be generated.

In loop unroll pass, the unrolled loop body will be unrolled another time by a
factor of two. The remainder loop will be unrolled by a factor of four. Two
extra loop prologues and a bunch of other checks will be generated. See the
bad.s attached.

If we disabled the unrolling in loop vectorization pass when VF==1, loop unroll
pass will do unrolling for the above loop by a factor of four all at once and
generate much less extra code like prologue and overflow checks. See the good.s
attached.

We experimentally disabled the unrolling in loop vectorization pass and saw the
internal benchmark improved 5% on sandybridge and 9% on westmere.

Google ref b/19469562

-- 
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/20150413/c07c78fb/attachment.html>


More information about the llvm-bugs mailing list