From: Steve Ellcey <sje@cup.hp.com>
To: gcc-patches@gcc.gnu.org
Cc: andreasmeier80@gmx.de
Subject: Patch for PR tree-optimization/32941, bootstrap comparision failure
Date: Fri, 10 Aug 2007 15:50:00 -0000 [thread overview]
Message-ID: <200708101549.IAA02582@hpsje.cup.hp.com> (raw)
This patch fixes PR tree-optimization/32941, a bootstrap comparision
failure. Currently we sort the goto_queue in tree-eh.c using qsort and
search it with bsearch. Because qsort is an unstable sort and we are
sorting on addresses we can get different orderings during different
bootstrap passes, resulting in the comparision failure.
This patch removes the sort and replaces the bsearch call with a simple
linear search. The obvious concern with this is compile time
performance but during a bootstrap the largest size goto_queue I saw was
7 elements and while compiling the C++ SPEC2006 benchmarks, the largest
size I saw was 30.
Given these relatively small sizes for the goto_queue, I think using a
linear search will not result in any compile time change or may actually
be faster since 99% of the time we search the queue the size is 1.
Tested with no regressions. OK for checkin?
Steve Ellcey
sje@cup.hp.com
2007-08-10 Steve Ellcey <sje@cup.hp.com>
PR tree-optimization/32941
* tree-eh.c (goto_queue_cmp): Remove.
(find_goto_replacement): Change bsearch call to linear search.
(lower_try_finally): Remove qsort call.
Index: tree-eh.c
===================================================================
--- tree-eh.c (revision 127288)
+++ tree-eh.c (working copy)
@@ -338,29 +338,17 @@ struct leh_tf_state
static void lower_eh_filter (struct leh_state *, tree *);
static void lower_eh_constructs_1 (struct leh_state *, tree *);
-/* Comparison function for qsort/bsearch. We're interested in
- searching goto queue elements for source statements. */
-
-static int
-goto_queue_cmp (const void *x, const void *y)
-{
- tree a = ((const struct goto_queue_node *)x)->stmt;
- tree b = ((const struct goto_queue_node *)y)->stmt;
- return (a == b ? 0 : a < b ? -1 : 1);
-}
-
/* Search for STMT in the goto queue. Return the replacement,
or null if the statement isn't in the queue. */
static tree
find_goto_replacement (struct leh_tf_state *tf, tree stmt)
{
- struct goto_queue_node tmp, *ret;
- tmp.stmt = stmt;
- ret = (struct goto_queue_node *)
- bsearch (&tmp, tf->goto_queue, tf->goto_queue_active,
- sizeof (struct goto_queue_node), goto_queue_cmp);
- return (ret ? ret->repl_stmt : NULL);
+ unsigned int i;
+ for (i = 0; i < tf->goto_queue_active; i++)
+ if (tf->goto_queue[i].stmt == stmt)
+ return tf->goto_queue[i].repl_stmt;
+ return NULL;
}
/* A subroutine of replace_goto_queue_1. Handles the sub-clauses of a
@@ -1371,11 +1359,6 @@ lower_try_finally (struct leh_state *sta
honor_protect_cleanup_actions (state, &this_state, &this_tf);
}
- /* Sort the goto queue for efficient searching later. */
- if (this_tf.goto_queue_active > 1)
- qsort (this_tf.goto_queue, this_tf.goto_queue_active,
- sizeof (struct goto_queue_node), goto_queue_cmp);
-
/* Determine how many edges (still) reach the finally block. Or rather,
how many destinations are reached by the finally block. Use this to
determine how we process the finally block itself. */
next reply other threads:[~2007-08-10 15:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-10 15:50 Steve Ellcey [this message]
2007-08-10 16:33 ` Ian Lance Taylor
2007-08-10 16:39 ` Diego Novillo
2007-08-10 21:45 ` Daniel Berlin
2007-08-10 21:58 ` Steve Ellcey
2007-08-10 22:05 ` Daniel Berlin
2007-08-10 22:18 ` Steve Ellcey
2007-08-10 22:00 ` Diego Novillo
2007-08-13 17:18 Steve Ellcey
2007-08-13 17:50 ` Ian Lance Taylor
2007-08-14 17:25 ` Steve Ellcey
2007-08-14 18:03 ` Steve Ellcey
2007-08-14 14:15 ` Diego Novillo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200708101549.IAA02582@hpsje.cup.hp.com \
--to=sje@cup.hp.com \
--cc=andreasmeier80@gmx.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).