public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* needless deep recursion in gt-c-decl.h
@ 2002-07-24  4:53 Per Bothner
  2002-07-24  5:17 ` Geoff Keating
  0 siblings, 1 reply; 117+ messages in thread
From: Per Bothner @ 2002-07-24  4:53 UTC (permalink / raw)
  To: gcc; +Cc: Geoffrey Keating

The gt_ggc_mx_lang_tree_node routine in the generated
gt-c-decl.h file causes a stack overflow when I tried
it under Darwin.  Perhaps I need to increase the stack
limit, but the deep recursion is a performance problem
that needlessly increases the working set.

Specifically, we should iterate, not recurse, on the
field that is most likely to be a long list, the TREE_CHAIN.
I don't understand how gengtype works, but the generated
code should be something like this:

void
gt_ggc_mx_lang_tree_node (x_p)
       void *x_p;
{
   union lang_tree_node * const x = (union lang_tree_node *)x_p;
   for (;;) {
     if (! ggc_test_and_set_mark (x))
       return;
   {
     ...
     gt_ggc_m_tree_node ((*x).generic.common.type);
     x = (*x).generic.common.chain;
     if (x != NULL_TREE)
       continue;
     return;
   }
}

All the comparisons against tag1 and tag2 may also be a performance
problem.  I don't know if the compiler is smart enough to convert
   if (tag2 == (TS_REAL_CST) ...;
   if (tag2 == (TS_VECTOR)) ...;
to:
   if (tag2 == (TS_REAL_CST) ...;
   else if (tag2 == (TS_VECTOR)) ...;
Assuming it is, it would still be an advantage if we could
order the type tests by frequency, unless the compiler is
smart enough to compile all the tests into a switch.  Is it?
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/

^ permalink raw reply	[flat|nested] 117+ messages in thread
* switch statement performance
@ 2004-01-20  2:19 Paul Vixie
  2004-01-20 22:13 ` Geoff Keating
  0 siblings, 1 reply; 117+ messages in thread
From: Paul Vixie @ 2004-01-20  2:19 UTC (permalink / raw)
  To: gcc

today i wanted to go on a performance-related witch hunt, so i added:

--------

--- stmt.c.orig Mon Jan 19 19:39:41 2004
+++ stmt.c      Mon Jan 19 19:57:25 2004
@@ -5393,6 +5393,12 @@
               || (TREE_CODE (index_expr) == COMPOUND_EXPR
                   && TREE_CODE (TREE_OPERAND (index_expr, 1)) == INTEGER_CST))
        {
+         /* If the sequence would be absurdly long and slow, send warning.  */
+         if (extra_warnings
+             && count >= case_values_threshold ()
+             && compare_tree_int (range, 10 * count) > 0)
+           warning ("large range, slow code");
+
          index = expand_expr (index_expr, NULL_RTX, VOIDmode, 0);
 
          /* If the index is a short or char that we do not have

--------

and then ran -W against bind8, bind9, the freebsd kernel, and other smaller
things.  the results weren't amazing or stupendous, but they were quite
useful.  one of the things i learned is that a lot of sparse switch stmts
should be left as they are for cleanliness reasons, since they are not
inside loops or otherwise called often enough to warrant rewriting them to
avoid the if-else code generation behaviour signalled by the above warning().

therefore if this were to become part of standard gcc, the following things
are desirable:

	1. it should be turned on with "-Wswitch-ifelse", not "-W".

	2. there should be a pragma or attribute to turn it off on
	   any given switch statement, if a code review finds that
	   it's not performance related.

sadly, i've already reached beyond the top end of my gcc hacking ability,
so if those things were to be done, i would need help learning how.  and
of course, i'd need "permission" in the form of some indication from you
folks that this change, if done properly, would be accepted back into gcc.

^ permalink raw reply	[flat|nested] 117+ messages in thread
[parent not found: <geoffk@geoffk.org>]
* PCH merge bootstrap failure on systems without flex
@ 2002-06-05 12:28 Kaveh R. Ghazi
  2002-06-05 19:37 ` Geoff Keating
  0 siblings, 1 reply; 117+ messages in thread
From: Kaveh R. Ghazi @ 2002-06-05 12:28 UTC (permalink / raw)
  To: geoffk; +Cc: gcc-bugs, gcc

I'm getting bootstrap failures in stage1 because there's no flex on my
box.

 > checking for flex... false
 > [...]
 > false  -o../../egcc-CVS20020605/gcc/gengtype-lex.c
 > ../../egcc-CVS20020605/gcc/gengtype-lex.l \
 >  || ( rm -f ../../egcc-CVS20020605/gcc/gengtype-lex.c && false )
 > make[2]: *** [../../egcc-CVS20020605/gcc/gengtype-lex.c] Error 255

Are we now requiring flex as part of the bootstrap process?  Was this
decision made knowingly or by accident?

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			Director of Systems Architecture
ghazi@caip.rutgers.edu		Qwest Solutions

^ permalink raw reply	[flat|nested] 117+ messages in thread
* Dumb register allocation (PPC)
@ 2002-05-12 12:50 Zack Weinberg
  2002-05-12 16:59 ` law
  0 siblings, 1 reply; 117+ messages in thread
From: Zack Weinberg @ 2002-05-12 12:50 UTC (permalink / raw)
  To: gcc

I noticed this while I was looking at something else.  This function

static hashval_t
const_double_htab_hash (x)
     const void *x;
{
  hashval_t h = 0;
  size_t i;
  rtx value = (rtx) x;

  for (i = 0; i < sizeof(CONST_DOUBLE_FORMAT)-1; i++)
    h ^= XWINT (value, i);
  return h;
}

gets compiled like this on PowerPC (-mregnames for clarity):

const_double_htab_hash:
	li	%r4, 3
	li	%r9, 0
	mtctr	%r4
	addi	%r3, %r3, 12
.L13:
	lwz	%r4, 0(%r3)
	addi	%r3, %r3, 8
	xor	%r9, %r9, %r4
	bdnz	.L13
	mr	%r3, %r9
	blr

Unless there is something weird about the architecture which I'm not
aware of, it appears that we could get rid of the final move
instruction by swapping %r9 and %r3.  %r3 holds the input parameter
but we've got three-operand add so that's not a difficulty.

const_double_htab_hash:
	li	%r4, 3
	addi	%r9, %r3, 12
	mtctr	%r4
	li	%r3, 0
.L13:
	lwz	%r4, 0(%r9)
	addi	%r9, %r9, 8
	xor	%r3, %r3, %r4
	bdnz	.L13
	blr

So why don't we do that automatically?  Presumably this is register
allocation's fault...

zw

^ permalink raw reply	[flat|nested] 117+ messages in thread
* PR 6394
@ 2002-04-29 14:36 Mark Mitchell
  2002-04-29 21:38 ` John David Anglin
  0 siblings, 1 reply; 117+ messages in thread
From: Mark Mitchell @ 2002-04-29 14:36 UTC (permalink / raw)
  To: law, dave.anglin; +Cc: gcc

PR 6394 is a floating-point ICE on PA 2.0, and is a regression from GCC
3.0, at least in the sense that we can no longer build Perl.

Jeff, do you have time to look at this?

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

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

end of thread, other threads:[~2004-01-21 21:38 UTC | newest]

Thread overview: 117+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-24  4:53 needless deep recursion in gt-c-decl.h Per Bothner
2002-07-24  5:17 ` Geoff Keating
2002-07-24  7:09   ` Per Bothner
2002-07-24  7:17     ` Geoff Keating
2002-07-24  7:52       ` Per Bothner
2002-07-25  2:32         ` Geoff Keating
2002-07-25 11:33           ` Per Bothner
2002-07-25 14:20             ` Geoff Keating
2002-07-26  8:37               ` Per Bothner
2002-07-30 21:41                 ` Geoff Keating
2002-07-31  1:40                   ` Per Bothner
2002-08-01 12:32                     ` Geoff Keating
2002-08-01 14:00                       ` Mike Stump
2002-08-01 16:00                         ` Geoff Keating
2002-08-01 19:17                       ` Richard Henderson
2002-08-05 10:06                       ` Per Bothner
2002-08-05 10:21                         ` Geoff Keating
2002-08-05 10:44                           ` Per Bothner
2002-08-05 11:14                             ` Geoff Keating
2002-08-05 11:36                               ` Per Bothner
2002-08-05 11:39                                 ` David Edelsohn
2002-08-05 11:56                                   ` Per Bothner
2002-08-05 12:08                                   ` Geoff Keating
2002-08-05 12:08                                 ` Geoff Keating
2002-08-05 13:23                                   ` David Edelsohn
2002-08-05 14:28                                   ` Per Bothner
2002-08-05 15:04                                     ` Geoff Keating
2002-08-05 15:37                                       ` Per Bothner
2002-08-05 16:15                                         ` Geoff Keating
2002-08-05 15:26                                     ` Zack Weinberg
2002-08-05 15:42                                       ` Per Bothner
  -- strict thread matches above, loose matches on Subject: below --
2004-01-20  2:19 switch statement performance Paul Vixie
2004-01-20 22:13 ` Geoff Keating
2004-01-20 22:26   ` Paul Vixie
2004-01-21  0:07     ` Geoff Keating
2004-01-21  0:29       ` Paul Vixie
2004-01-21  4:13         ` Ian Lance Taylor
2004-01-21  5:15           ` Paul Vixie
2004-01-21 21:54         ` tm_gccmail
     [not found] <geoffk@geoffk.org>
2002-06-10 10:31 ` whither specs? Geoff Keating
2002-06-10 10:55   ` David Edelsohn
2002-06-10 10:56     ` Geoff Keating
2002-06-10 11:01       ` H . J . Lu
2002-06-10 11:18       ` David Edelsohn
2002-06-10 11:47       ` Mumit Khan
2002-06-11 16:48         ` Jason R Thorpe
2002-06-12  1:20           ` Theodore Papadopoulo
2002-06-12 11:01           ` Richard Henderson
2002-06-12 11:36             ` Theodore Papadopoulo
2002-06-12 15:48               ` Richard Henderson
2002-06-12 16:54               ` H . J . Lu
2002-11-24  6:52                 ` Jason R Thorpe
2002-11-24  7:07                   ` H. J. Lu
2002-11-25 10:01                     ` Theodore Papadopoulo
2002-11-25 10:05                       ` Jason R Thorpe
2002-11-25 14:40                         ` Theodore Papadopoulo
2002-11-25 10:37                       ` H. J. Lu
2002-06-10 15:01       ` Matthias Benkmann
2002-06-10 12:17   ` Tom Tromey
2002-06-10 15:37   ` Zack Weinberg
2002-06-10 19:25   ` Mark Mitchell
2002-06-05 12:28 PCH merge bootstrap failure on systems without flex Kaveh R. Ghazi
2002-06-05 19:37 ` Geoff Keating
2002-06-05 19:59   ` David Edelsohn
2002-06-05 20:22     ` Kaveh R. Ghazi
2002-06-10  0:01       ` Mark Mitchell
2002-06-10  3:17         ` Gerald Pfeifer
2002-06-10  7:48           ` Kaveh R. Ghazi
     [not found]         ` <Pine.BSF.4.44.0206101202120.46487-100000@naos.dbai.tuwien. ac.at>
2002-06-10  5:41           ` Andrea 'Fyre Wyzard' Bocci
2002-06-05 20:37     ` Geoff Keating
2002-05-12 12:50 Dumb register allocation (PPC) Zack Weinberg
2002-05-12 16:59 ` law
2002-05-12 21:38   ` David Edelsohn
2002-05-12 22:44     ` Zack Weinberg
2002-05-13 18:20       ` Richard Henderson
2002-05-14 13:15     ` Dale Johannesen
2002-05-14 13:15       ` David Edelsohn
2002-05-15  0:00         ` Richard Henderson
2002-05-15  8:27           ` David Edelsohn
2002-05-15 11:47             ` Geoff Keating
2002-05-15 12:08               ` law
2002-05-15 11:50             ` David Edelsohn
2002-05-15 12:38               ` law
2002-05-15 12:43               ` Geoff Keating
2002-05-15 12:55                 ` David Edelsohn
2002-04-29 14:36 PR 6394 Mark Mitchell
2002-04-29 21:38 ` John David Anglin
2002-04-30 10:31   ` David Edelsohn
2002-04-30 10:48     ` John David Anglin
2002-04-30 18:48       ` law
2002-04-30 19:55         ` John David Anglin
2002-04-30 20:43           ` law
2002-04-30 21:06             ` John David Anglin
2002-04-30 12:56     ` Geoff Keating
2002-04-30 13:07       ` David Edelsohn
2002-04-30 13:12         ` John David Anglin
2002-04-30 13:37           ` Geoff Keating
2002-04-30 13:41             ` David Edelsohn
2002-04-30 14:07               ` law
2002-04-30 14:28                 ` John David Anglin
2002-04-30 13:59             ` John David Anglin
2002-04-30 14:04           ` law
2002-04-30 14:39             ` John David Anglin
2002-04-30 14:54               ` law
2002-04-30 15:04                 ` John David Anglin
2002-04-30 15:23               ` law
2002-04-30 15:29                 ` John David Anglin
2002-04-30 15:52                   ` law
2002-04-30 16:11               ` law
2002-04-30 16:27                 ` John David Anglin
2002-04-30 16:41                   ` law
2002-04-30 18:46                   ` law
2002-04-30 20:18                     ` John David Anglin
2002-05-01  7:17                     ` Peter Barada
2002-04-30 16:34                 ` Geoff Keating
2002-04-30 17:04                   ` law
2002-04-30 18:48                   ` law

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).