[llvm-bugs] [Bug 39027] New: Slow code generated when compared to gcc; loop unrolling; AVX/vectorization

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 20 13:05:51 PDT 2018


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

            Bug ID: 39027
           Summary: Slow code generated when compared to gcc; loop
                    unrolling; AVX/vectorization
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvmbugs at wulf.eu.org
                CC: llvm-bugs at lists.llvm.org

Created attachment 20900
  --> https://bugs.llvm.org/attachment.cgi?id=20900&action=edit
C code and generated assembly

Hello.

Following C code runs in about 3.3s with gcc and about 16s with clang:

#include <stdio.h>

static int f(unsigned int i)
{
    return ((i & 0x7f) != i);
}

int main(void)
{
    for (int z = 0; z < 10; ++z) {
        unsigned i = 0;
        unsigned j = 0;
        do {
            if (f(i)) ++j;
        } while (++i);

        printf("%u\n", j);
    }
}

Code and generated assembly code is included in the attachment. Clang does some
loop unrolling, gcc uses instructions like "vmovdqa".

I hope these details suffice to reproduce the issue and improve clang/llvm.



System: Debian Unstable, Intel(R) Core(TM) i7-7500U
CPU Flags:
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush
dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm
constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc
cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2
ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt
tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch
cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi
flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx
rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida
arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d

gcc: 8.2.0
clang: 6.0.1-6
compile command: [gcc/clang] -O3 -g0 -o test -march=native test.c

-- 
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/20180920/f83d7a63/attachment.html>


More information about the llvm-bugs mailing list