This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/11823] Optimizing large jump tables for switch statements


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]