Re: GCC/G++ compiler: Error goes away when run through debugger

George Neuner <gneuner2@comcast.net>
Thu, 31 Mar 2011 01:34:30 -0400

          From comp.compilers

Related articles
[4 earlier articles]
Re: GCC/G++ compiler: Error goes away when run through debugger Pidgeot18@verizon.invalid (Joshua Cranmer) (2011-03-27)
Re: GCC/G++ compiler: Error goes away when run through debugger torbenm@diku.dk (2011-03-28)
Re: GCC/G++ compiler: Error goes away when run through debugger bc@freeuk.com (BartC) (2011-03-28)
Re: GCC/G++ compiler: Error goes away when run through debugger gneuner2@comcast.net (George Neuner) (2011-03-29)
Re: GCC/G++ compiler: Error goes away when run through debugger gah@ugcs.caltech.edu (glen herrmannsfeldt) (2011-03-29)
Re: GCC/G++ compiler: Error goes away when run through debugger ike@localhost.claranet.nl (2011-03-29)
Re: GCC/G++ compiler: Error goes away when run through debugger gneuner2@comcast.net (George Neuner) (2011-03-31)
Re: GCC/G++ compiler: Error goes away when run through debugger shankarke@gmail.com (Shankar) (2011-04-01)
| List of all articles for this month |
From: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: Thu, 31 Mar 2011 01:34:30 -0400
Organization: A noiseless patient Spider
References: 11-03-054 11-03-061 11-03-063
Keywords: GCC, debug, optimize
Posted-Date: 02 Apr 2011 19:45:52 EDT

On Tue, 29 Mar 2011 21:42:12 +0000 (UTC), ike@localhost.claranet.nl
(Ike Naar) wrote:


>George Neuner <gneuner2@comcast.net> wrote:
>>GCC's -O3 optimization level is widely known to cause strange problems
>>... almost always because the program is violating assumptions made by
>>the more advanced optimizations.
>>
>>The -O2 level typically is safe. If you think you need the -O3
>>optimizations, you should individually enable them to see if any
>>breaks the program. Specify -O3 only if you find they all work.
>
>Sometimes using -O3 makes the program run slower than when using -O2.


Yes, inlining and function cloning can greatly increase the code size.
But in particular -O3 enables the "predictive-commoning" and
"tree-vectorize" optimizations. "predictive-commoning" is an
extension of loop unrolling which tries to identify and avoid
recomputing and/or reloading values that are common to two or more
(not necessarily consecutive) iterations of a loop but which overall
are not loop invariant. "tree-vectorize" tries to map a loop of
serial operations into an equivalent, but shorter, loop of SIMD
operations. Both of these optimizations can break badly - and in
quite unexpected ways - when indexed locations are aliased or when
there are iterative data dependencies. The compiler can't always
figure out when NOT to perform the optimization ... and the results
when the compiler guesses wrong are unpredictable.


George



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.