This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/11823] Optimizing large jump tables for switch statements
- From: "steven at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Aug 2003 13:01:04 -0000
- Subject: [Bug middle-end/11823] Optimizing large jump tables for switch statements
- References: <20030806083958.11823.alga@rgai.hu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11823
------- Additional Comments From steven at gcc dot gnu dot org 2003-08-07 13:01 -------
You should look at stmt.c:expand_end_case_type(), under the comment:
/* If range of values is much bigger than number of values,
make a sequence of conditional branches instead of a dispatch.
If the switch-index is a constant, do it this way
because we can optimize it. */
The heuristic following this comment now does:
|| compare_tree_int (range, 10 * count) > 0
where "count" is the number of case labels, and range is the range of the case
labels. In your example, count==11, and range==110, so you just hit the case
where it still gets expanded with a jump table. (I suppose you knew this,
judging from your example ;-)
So why not replace this heuristic with something like:
|| compare_tree_int (range, (optimize_size ? 3 : 10) * count) > 0
and see if it helps...