Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* other gcc problem
@ 1996-05-14 17:40 Harald Koenig
  1996-05-14 21:56 ` Richard Henderson
  1996-05-15  6:46 ` Richard Henderson
  0 siblings, 2 replies; 6+ messages in thread
From: Harald Koenig @ 1996-05-14 17:40 UTC (permalink / raw)


compiling PEX support for X11 I found another strange problem with gcc.
the compilation of 

	xc/programs/Xserver/PEX5/ddpex/mi/level4/miWks.c

with anything but "-O0" takes >800 seconds on a XL266,  "-O0" takes only
~3 seconds  and on my i486 "gcc -O2" takes ~9 seconds.

this file is ~65k large, a cpp'ed source file is ~140k in 5500 lines
with nothing special.

any idea?  anyone wants this source file to check ?

Harald

-- 
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

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

* Re: other gcc problem
@ 1996-05-14 20:57 David Mosberger
  0 siblings, 0 replies; 6+ messages in thread
From: David Mosberger @ 1996-05-14 20:57 UTC (permalink / raw)


Does that file have a large initialized array, by any chance?
I noticed that initialized arrays seem to take O(N^2) memory.
An initialized array of several thousand entries is gonna blow
away 32MBs of memory just like nothing with gcc (that's one reason
MILO generates an assembly file instead).  I think that has been a
problem ever since c++ support was added.

	--david

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

* Re: other gcc problem
       [not found] <199605142057.NAA05396@web.azstarnet.com>
@ 1996-05-14 21:36 ` Harald Koenig
  0 siblings, 0 replies; 6+ messages in thread
From: Harald Koenig @ 1996-05-14 21:36 UTC (permalink / raw)


> Does that file have a large initialized array, by any chance?
> I noticed that initialized arrays seem to take O(N^2) memory.

no.  does this initialisation depend of the optimisation level ?

> An initialized array of several thousand entries is gonna blow
> away 32MBs of memory just like nothing with gcc (that's one reason
> MILO generates an assembly file instead).  I think that has been a
> problem ever since c++ support was added.

cc1 only takes ~4.5MB memory and just sucks CPU time for 10+ minutes
with -O -01 -O2 etc. (but not -O0).

I've stripped down the source file and located the function which takes
all the CPU time; below it is.  this is extracted and a bit normalized
from the original source file.  if you define ONLY_2_SECONDS compilation
with -O1 or -O2 will need ~2 seconds, every additional line will increase
the CPU time needed dramatically...

Harald

-------------------------------------------------------------------------------
long func(long mask[2])
{
  long needbytes=0;

  if (mask[(( 0)/32)] & (((unsigned long)1) << (( 0) % 32))) needbytes += (4) ;
  if (mask[(( 1)/32)] & (((unsigned long)1) << (( 1) % 32))) needbytes += (4) ;
  if (mask[(( 2)/32)] & (((unsigned long)1) << (( 2) % 32))) needbytes += (4) ;
  if (mask[(( 3)/32)] & (((unsigned long)1) << (( 3) % 32))) needbytes += (4) ;
  if (mask[(( 4)/32)] & (((unsigned long)1) << (( 4) % 32))) needbytes += (4) ;
  if (mask[(( 5)/32)] & (((unsigned long)1) << (( 5) % 32))) needbytes += (4) ;
  if (mask[(( 6)/32)] & (((unsigned long)1) << (( 6) % 32))) needbytes += (24) ;
  if (mask[(( 7)/32)] & (((unsigned long)1) << (( 7) % 32))) needbytes += (24) ;
  if (mask[(( 8)/32)] & (((unsigned long)1) << (( 8) % 32))) needbytes += (20) ;
  if (mask[(( 9)/32)] & (((unsigned long)1) << (( 9) % 32))) needbytes += (20) ;
  if (mask[((10)/32)] & (((unsigned long)1) << ((10) % 32))) needbytes += (4) ;
  if (mask[((11)/32)] & (((unsigned long)1) << ((11) % 32))) needbytes += (4) ;
  if (mask[((12)/32)] & (((unsigned long)1) << ((12) % 32))) needbytes += (4) ;
  if (mask[((13)/32)] & (((unsigned long)1) << ((13) % 32))) needbytes += (4) ;
  if (mask[((14)/32)] & (((unsigned long)1) << ((14) % 32))) needbytes += (4) ;
  if (mask[((15)/32)] & (((unsigned long)1) << ((15) % 32))) needbytes += (4) ;
  if (mask[((16)/32)] & (((unsigned long)1) << ((16) % 32))) needbytes += (4) ;
#ifndef ONLY_2_SECONDS
  if (mask[((17)/32)] & (((unsigned long)1) << ((17) % 32))) needbytes += (4) ;
  if (mask[((18)/32)] & (((unsigned long)1) << ((18) % 32))) needbytes += (4) ;
  if (mask[((19)/32)] & (((unsigned long)1) << ((19) % 32))) needbytes += (4) ;
  if (mask[((20)/32)] & (((unsigned long)1) << ((20) % 32))) needbytes += (4) ;
  if (mask[((21)/32)] & (((unsigned long)1) << ((21) % 32))) needbytes += (4) ;
  if (mask[((22)/32)] & (((unsigned long)1) << ((22) % 32))) needbytes += (4) ;
  if (mask[((23)/32)] & (((unsigned long)1) << ((23) % 32))) needbytes += (4) ;
  if (mask[((24)/32)] & (((unsigned long)1) << ((24) % 32))) needbytes += (4) ;
  if (mask[((25)/32)] & (((unsigned long)1) << ((25) % 32))) needbytes += (4) ;
  if (mask[((26)/32)] & (((unsigned long)1) << ((26) % 32))) needbytes += (4) ;
  if (mask[((27)/32)] & (((unsigned long)1) << ((27) % 32))) needbytes += (4) ;
  if (mask[((28)/32)] & (((unsigned long)1) << ((28) % 32))) needbytes += (4) ;
  if (mask[((29)/32)] & (((unsigned long)1) << ((29) % 32))) needbytes += (4) ;
  if (mask[((30)/32)] & (((unsigned long)1) << ((30) % 32))) needbytes += (4) ;
  if (mask[((31)/32)] & (((unsigned long)1) << ((31) % 32))) needbytes += (4) ;
  if (mask[((33)/32)] & (((unsigned long)1) << ((33) % 32))) needbytes += (4) ;
  if (mask[((32)/32)] & (((unsigned long)1) << ((32) % 32))) needbytes += (4) ;
#endif

  return needbytes;
}
-------------------------------------------------------------------------------

-- 
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

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

* Re: other gcc problem
  1996-05-14 17:40 other gcc problem Harald Koenig
@ 1996-05-14 21:56 ` Richard Henderson
  1996-05-14 23:01   ` Harald Koenig
  1996-05-15  6:46 ` Richard Henderson
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Henderson @ 1996-05-14 21:56 UTC (permalink / raw)


> with anything but "-O0" takes >800 seconds on a XL266,  "-O0" takes only
> ~3 seconds  and on my i486 "gcc -O2" takes ~9 seconds.
> 
> this file is ~65k large, a cpp'ed source file is ~140k in 5500 lines
> with nothing special.
> 
> any idea?  anyone wants this source file to check ?

Hmm.  Sounds odd.  Send me the pre-processed file and I'll check 
it out.  What gcc version and patches are you using?

r~

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

* Re: other gcc problem
  1996-05-14 21:56 ` Richard Henderson
@ 1996-05-14 23:01   ` Harald Koenig
  0 siblings, 0 replies; 6+ messages in thread
From: Harald Koenig @ 1996-05-14 23:01 UTC (permalink / raw)


> > this file is ~65k large, a cpp'ed source file is ~140k in 5500 lines
> > with nothing special.

> Hmm.  Sounds odd.  Send me the pre-processed file and I'll check 
> it out.  

now the sample code is *much* smaller; I've just mailed it to the list.

> What gcc version and patches are you using?

gccaxp-2.7.1-3.axp.rpm  from Red Hat 3.0.3.

Harald

-- 
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

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

* Re: other gcc problem
  1996-05-14 17:40 other gcc problem Harald Koenig
  1996-05-14 21:56 ` Richard Henderson
@ 1996-05-15  6:46 ` Richard Henderson
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Henderson @ 1996-05-15  6:46 UTC (permalink / raw)


> with anything but "-O0" takes >800 seconds on a XL266,  "-O0" takes only
> ~3 seconds  and on my i486 "gcc -O2" takes ~9 seconds.

There is a bit of over-aggressiveness in the combiner as it tries
to simplify the entire function as a set of nested if-then-else
expressions to see if the return value is constant.

Unfortunately, this creates an expression tree that leads to
exponential run-times later on.

I would suspect this nastiness to be triggered on any target that 
supports conditional moves.  Which explains why the problem does
not show up on the i386 target.

Though this is not a particularly good solution, it will let you
get on with your work while a more permanent fix is explored.
Expect a bit of fuzz on the patch.

r~

--- combine.c.orig      Tue Apr 16 15:00:58 1996
+++ combine.c   Wed May 15 00:50:41 1996
@@ -3049,6 +3086,8 @@ simplify_rtx (x, op0_mode, last, in_dest
       SUBST (XEXP (x, 0), gen_binary (PLUS, mode, new, temp));
     }
 
+#if 0
+  /* While logically correct, this can result in exponential run time. */
   /* If this is a simple operation applied to an IF_THEN_ELSE, try 
      applying it to the arms of the IF_THEN_ELSE.  This often simplifies
      things.  Check for cases where both arms are testing the same
@@ -3120,6 +3159,7 @@ simplify_rtx (x, op0_mode, last, in_dest
          op0_mode = VOIDmode;
        }
     }
+#endif
 
   /* Try to fold this expression in case we have constants that weren't
      present before.  */

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

end of thread, other threads:[~1996-05-15  6:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-05-14 17:40 other gcc problem Harald Koenig
1996-05-14 21:56 ` Richard Henderson
1996-05-14 23:01   ` Harald Koenig
1996-05-15  6:46 ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
1996-05-14 20:57 David Mosberger
     [not found] <199605142057.NAA05396@web.azstarnet.com>
1996-05-14 21:36 ` Harald Koenig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox