[llvm-bugs] [Bug 30939] New: bubble sort test performance is 2 times worse with -unroll-runtime-epilog

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 7 15:05:31 PST 2016


            Bug ID: 30939
           Summary: bubble sort test performance is 2 times worse with
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: evstupac at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 17562
  --> https://llvm.org/bugs/attachment.cgi?id=17562&action=edit
test compiled with epilog

The performance difference between prologue and epilogue unroll is unclear for
the case.

performance differs 2 times on X86 when
SingleSource/Benchmarks/Stanford/Bubblesort.c is compiled with

-O2 -march=core-avx2 -mllvm -unroll-runtime-epilog=true (bad case)
-O2 -march=core-avx2 -mllvm -unroll-runtime-epilog=false (good case)

Attached assemblies from current compiler:
and assembly from hottest loop:

The code looks very similar and with some assembly modifications I was able to
make hottest loops identical keeping the same performance gap (2 times).

Deeper analysis uncovered that hottest loop (99% of execution time) mostly
consist of unpredictable branches stalls:

while ( i<top ) {    
    if ( sortlist[i] > sortlist[i+1] ) {
        j = sortlist[i];
        sortlist[i] = sortlist[i+1];
        sortlist[i+1] = j;

sortlist is randomly filled array. That way comparison in the loop is
completely unpredictable. The distance between branches is very short.
This makes the test very sensitive to code shifts and memory accesses order (as
it influence on branch prediction in the loop).

See related discussions:

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/20161107/749eeff1/attachment.html>

More information about the llvm-bugs mailing list