[llvm-bugs] [Bug 51953] New: super slow complication with -O3 on simple valid code (-O2: 0.1s VS -O3: 8min+)

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 24 01:31:03 PDT 2021


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

            Bug ID: 51953
           Summary: super slow complication with -O3 on simple valid code
                    (-O2: 0.1s VS -O3: 8min+)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hi all.

The trunk of clang spends too much time compiling the following simple valid
code at -O3. 

$cat small.c
#include <stdint.h>
ui_0 = 0x7DED4A39;
ui_1 = 0x8CD77211;
uli_3 = 0x0;
us_8 = 0x0;
li_9 = 0x94B16C262177BA8F;
c_11 = 0x0;
s_14 = 0x6A5F;
uli_15 = 0x8F4F05DD1902F8E5;
uint32_t ui_16 = 0xE91854DB;
int32_t func() {
  for (uli_3 = 18; c_11 <= 40; c_11 += 1)
    do {
      ui_0 = 6;
      for (; ui_0 > 2; ui_0--) {
        c_11 = 7;
        do {
          (ui_16 &= s_14);
          do {
            ui_1 = -4;
            do {
              ui_1 += 4;
              li_9 = 5;
              do
                if ((ui_16 &= s_14)) {
                  while (uli_15 > 2)
                    ;
                }
              while (li_9--);
            } while (ui_1 < 100);
          } while (0);
        } while (c_11--);
      }
    } while (us_8++);
}

$time clang -w -O2 -c small.c

real    0m0.118s
user    0m0.058s
sys     0m0.030s

$time clang -w -O3 -c small.c

real    8m37.672s
user    7m32.836s
sys     0m11.836s


$clang -v
clang version 14.0.0 (https://github.com/llvm/llvm-project
ebc5feb4ed6b1f59a000669030f9639bf1763403)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/haoxin-data/compilers/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64


Reproduced in Godbolt: https://godbolt.org/z/vn5fqWe6f

Thanks
Haoxin

-- 
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/20210924/0970a028/attachment-0001.html>


More information about the llvm-bugs mailing list