Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: Have you ever noticed ... Date: Tue, 01 Jun 2021 18:24:12 -0700 Organization: None to speak of Lines: 55 Message-ID: <87a6o9xdmr.fsf@nosuchdomain.example.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="250530747ae9408d308e379afa6e16fd"; logging-data="23365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Tr/pw18Iy0rRQp8xpe+4Q" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:puj13GizJ/FX/kMbmCsFHQpKlqw= sha1:P9gS9xihS7HFpqLSCe64dyl2U3E= Xref: csiph.com comp.lang.c++:80062 Michael S writes: > On Tuesday, June 1, 2021 at 12:54:30 PM UTC+3, David Brown wrote: >> On 01/06/2021 11:06, Bonita Montero wrote: >> >>> If you call ... >> >>> C:\Program Files (x86)\Microsoft Visual >> >>> Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat >> >>> ... and then ... >> >>> clang --version >> >>> ... then you get the nearly most recent clang (V11) with MSVC ? >> >>> But unfortunately for most benchmarks I wrote MSVC generates >> >>> better code than clang. >> > >> >> What optimization flags did you use? >> > >> > -O3 >> > There are also benchmarks which run faster with clang, >> > but most run faster with cl. >> -O3 is sometimes faster than -O2, and often slower. Don't use -O3 >> unless you know what you are doing, and have tested it to see that it is >> helpful for your particular requirements. (The same applies to gcc, to >> a slightly lesser extent.) >> >> clang also has a tendency to be enthusiastic about vectorisation and >> loop unrolling that can help for big data sets, but be noticeably bigger >> and slower on small sets. You see that especially on -O3, but also on >> -O2. Optimising is not just a matter of "bigger number means faster for >> all tests". >> >> (That said, MSVC can be quite efficient for some kinds of code - it's >> entirely possible that it is simply better for the examples you were using.) > > I was under impression that in clang -O3 is the same as -O2. A flag > that exists for compatibility with gcc and nothing else. As of version 12.0.0, "man clang" says: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -Og, -O, -O4 Specify which optimization level to use: -O0 Means “no optimization”: this level compiles the fastest and generates the most debuggable code. -O1 Somewhere between -O0 and -O2. -O2 Moderate level of optimization which enables most optimizations. -O3 Like -O2, except that it enables optimizations that take longer to perform or that may generate larger code (in an attempt to make the program run faster). -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */