[llvm-bugs] [Bug 43084] New: Compiling with -O1 is slower than -O2

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 22 01:21:13 PDT 2019


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

            Bug ID: 43084
           Summary: Compiling with -O1 is slower than -O2
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hehaochen13 at nudt.edu.cn
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Created attachment 22412
  --> https://bugs.llvm.org/attachment.cgi?id=22412&action=edit
from clangBug-14651

See the following results:

##### This is normal ##### 
-- clang version 3.4.2 --(CentOS Linux release 7.6.1810 Core) 
time clang++ -O0 -w tramp3d-v4.cpp  5.951s
time clang++ -O1 -w tramp3d-v4.cpp  9.890s
time clang++ -O2 -w tramp3d-v4.cpp  12.931s
time clang++ -O3 -w tramp3d-v4.cpp  14.078s
time clang++ -Os -w tramp3d-v4.cpp  11.100s
time clang++ -Ofast -w tramp3d-v4.cpp  14.107s

##### This is normal #####
-- Apple clang version 11.0.0 (clang-1100.0.20.17) --(MacOS Mojave 10.14.6)
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -O0 -o files pan.c  1.176s
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -O1 -o files pan.c  12.805s
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -O2 -o files pan.c  20.955s
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -O3 -o files pan.c  20.907s
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -Os -o files pan.c  17.487s
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -Ofast -o files pan.c  20.362s

##### This is NOT normal #####
-- clang version 3.4.2 --(CentOS Linux release 7.6.1810 Core)
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -O0 -o files pan.c  1.440s
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -O1 -o files pan.c  37.666s //
This is NOT normal
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -O2 -o files pan.c  26.200s
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -O3 -o files pan.c  26.780s
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -Os -o files pan.c  18.114s
time clang -DHC4 -DSAFETY -DNOREDUCE -DNFAIR=3 -Ofast -o files pan.c  26.185s

pan.c is from clang-14651(https://bugs.llvm.org/show_bug.cgi?id=14651), while
tramp3d-v4 is an open source benchmark.

As described in the GCC documentation: "-O2 turns on all optimization flags
specified by -O1 and it also turns on the following optimization flags: xxx,
xxx..."(and I think it is similar in
clang(https://stackoverflow.com/questions/15548023/clang-optimization-levels))
So I think compiling with -O1 are not expected to be slower than that with -O2.
So I think this may be a performance bug.

-- 
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/20190822/53f28aa1/attachment.html>


More information about the llvm-bugs mailing list