public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc 4.1 -O1 problem
@ 2006-03-16  4:49 Kevin Shanahan
  2006-03-16  5:57 ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Shanahan @ 2006-03-16  4:49 UTC (permalink / raw)
  To: gcc-help

Hi,

I've come across a problem with my program when compiling with gcc-4.1
as opposed to gcc-4.0. With 4.1, the sound output comes out as
corrupted. I've narrowed it down to a single source file, and the fact
that it works with -O0 but not -O1.

However, I've tried to find the specific optimisation flag that is
causing the issue and I've come up against the situation below:

If I compile with -O0 and each of the flags below, the sound output is
working again. If I compile with -O1 and each of the options below
changed to -fno-... then the sound corruption is back:

          -fdefer-pop 
          -fdelayed-branch 
          -fguess-branch-probability 
          -fcprop-registers 
          -floop-optimize 
          -fif-conversion 
          -fif-conversion2 
          -ftree-ccp 
          -ftree-dce 
          -ftree-dominator-opts 
          -ftree-dse 
          -ftree-ter 
          -ftree-lrs 
          -ftree-sra 
          -ftree-copyrename 
          -ftree-fre 
          -ftree-ch 
          -fmerge-constants

Are there any other options besides these which -O1 affects?
Any other ideas as to how I can narrow down the cause?

Thanks,
Kevin.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc 4.1 -O1 problem
  2006-03-16  4:49 gcc 4.1 -O1 problem Kevin Shanahan
@ 2006-03-16  5:57 ` Ian Lance Taylor
  2006-03-16  6:11   ` Kevin Shanahan
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2006-03-16  5:57 UTC (permalink / raw)
  To: Kevin Shanahan; +Cc: gcc-help

Kevin Shanahan <kmshanah@disenchant.net> writes:

> Are there any other options besides these which -O1 affects?

-O1 is unfortunately not the sum of individual options.  The compiler
often simply checks whether you are optimizing at all, rather than
checking specific options.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc 4.1 -O1 problem
  2006-03-16  5:57 ` Ian Lance Taylor
@ 2006-03-16  6:11   ` Kevin Shanahan
  2006-03-16 12:50     ` John Love-Jensen
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Shanahan @ 2006-03-16  6:11 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

On Wed, Mar 15, 2006 at 09:57:13PM -0800, Ian Lance Taylor wrote:
> Kevin Shanahan <kmshanah@disenchant.net> writes:
> > Are there any other options besides these which -O1 affects?
> 
> -O1 is unfortunately not the sum of individual options.  The compiler
> often simply checks whether you are optimizing at all, rather than
> checking specific options.

Okay, thanks anyway. I found out that the signed char cast in this
snippet of code changed behaviour with -O1:

    int snd_scaletable[32][256];
    int i, j;

    for (i = 0; i < 32; i++)
	for (j = 0; j < 256; j++)
	    snd_scaletable[i][j] = ((signed char)j) * i * 8;

I made the value explicit as '(j < 128) ? j : j - 256' instead.

Cheers,
Kevin.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc 4.1 -O1 problem
  2006-03-16  6:11   ` Kevin Shanahan
@ 2006-03-16 12:50     ` John Love-Jensen
  2006-03-16 18:38       ` Kevin Shanahan
  0 siblings, 1 reply; 5+ messages in thread
From: John Love-Jensen @ 2006-03-16 12:50 UTC (permalink / raw)
  To: Kevin Shanahan; +Cc: MSX to GCC

Hi Kevin,

I think your code is correct, and the GCC 4.1 compiler has a boo-boo.  File
a bug report, please, including the code snippet that reproduces the
suspected bug, what platform, and the command line used to compile the code.
See "Bugs" section on the left column of <http://gcc.gnu.org/>.

Anyway, here's a couple bits of tid (as I understand it):

-O0 disables all optimizations.  The -fenable-something likely don't enable
the specified optimization when -O0 is specified (if there are exceptions,
I'm not aware of them).

-fverbose-asm (with -S or -save-temps) is useful to ascertain what
optimizations are happenings with -O1, -O2, -O3, -Os.

As I understand it, only select optimizations are twiddlible with -f flags,
but not all of the possible optimizations.

HTH,
--Eljay

PS:  twiddlible ... *heh*

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc 4.1 -O1 problem
  2006-03-16 12:50     ` John Love-Jensen
@ 2006-03-16 18:38       ` Kevin Shanahan
  0 siblings, 0 replies; 5+ messages in thread
From: Kevin Shanahan @ 2006-03-16 18:38 UTC (permalink / raw)
  To: John Love-Jensen; +Cc: MSX to GCC

On Thu, Mar 16, 2006 at 06:50:42AM -0600, John Love-Jensen wrote:
> I think your code is correct, and the GCC 4.1 compiler has a boo-boo.  File
> a bug report, please, including the code snippet that reproduces the
> suspected bug, what platform, and the command line used to compile the code.
> See "Bugs" section on the left column of <http://gcc.gnu.org/>.

Okay, thanks. I've filed this as bug #26719.

> Anyway, here's a couple bits of tid (as I understand it):
> 
> -O0 disables all optimizations.  The -fenable-something likely don't enable
> the specified optimization when -O0 is specified (if there are exceptions,
> I'm not aware of them).

I tried with and without -O0 specified; it didn't seem to make a
difference.

> -fverbose-asm (with -S or -save-temps) is useful to ascertain what
> optimizations are happenings with -O1, -O2, -O3, -Os.

Using -fverbose-asm and -save-temps, it seems to show a few more
optimisations being used than the man page indicates. I might try a
few of those and add it to the bug info if it makes a difference.

Cheers,
Kevin.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-03-16 18:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-16  4:49 gcc 4.1 -O1 problem Kevin Shanahan
2006-03-16  5:57 ` Ian Lance Taylor
2006-03-16  6:11   ` Kevin Shanahan
2006-03-16 12:50     ` John Love-Jensen
2006-03-16 18:38       ` Kevin Shanahan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).