[Bug middle-end/11823] Optimizing large jump tables for switch statements
steven at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu Aug 7 13:01:00 GMT 2003
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...
More information about the Gcc-bugs
mailing list