[LLVMdev] LLVM compile speed significantly slower than GCC (w/ test case)

Renato Golin rengolin at systemcall.org
Fri Jul 20 01:45:58 PDT 2012


>> GCC (4.5.2, Windows build from CodeSourcery) - With -O0: 110ms, with -O2: 215ms
>> Clang/LLVM (Release mode, LLVM git hash 7f5714f4..., clang git hash
>> 9d9cf5...) - With -O0: 110ms, with -O2: 640ms

Hi Matt,

I only see 2x slowdown on my machine (consistently, O2 and O3), but
that's still bad.

If you compile to IR then pass "opt -time-passes" you can get a good
idea who the culprit is:

$ clang -O0 -S -emit-llvm sha1test.c
$ opt -time-passes -O2 sha1test.s
(...)
   ---User Time---   --System Time--   --User+System--   ---Wall
Time---  --- Name ---
   0.2720 ( 54.0%)   0.0000 (  0.0%)   0.2720 ( 53.5%)   0.2821 (
52.8%)  Combine redundant instructions
   0.1160 ( 23.0%)   0.0000 (  0.0%)   0.1160 ( 22.8%)   0.1162 (
21.8%)  Combine redundant instructions
   0.0600 ( 11.9%)   0.0000 (  0.0%)   0.0600 ( 11.8%)   0.0610 (
11.4%)  Combine redundant instructions
   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0205 (
3.8%)  Early CSE
   0.0240 (  4.8%)   0.0000 (  0.0%)   0.0240 (  4.7%)   0.0204 (
3.8%)  Combine redundant instructions
   0.0200 (  4.0%)   0.0000 (  0.0%)   0.0200 (  3.9%)   0.0203 (
3.8%)  Combine redundant instructions
(...)

That's roughly 99% user / 97% wall clock.

Seeing from your source, you have a few simple macros repeated over
and over, which will stress the combiner, for sure.

This is a great micro-benchmark (and a very common pattern), thanks
for the report!

-- 
cheers,
--renato

http://systemcall.org/



More information about the llvm-dev mailing list