This is the mail archive of the gcc-patches@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]

Re: casesi with HImode index



Hi All,

On Wed, 29 Nov 2000, Michael Meissner wrote:

> On Wed, Nov 29, 2000 at 06:19:09PM +0100, Marek Michalkiewicz wrote:
> >
> > Please consider this or similar change to allow the "casesi" pattern
> > to specify a mode different from SImode for operand 0 (index).
> > As I understand it (please correct if wrong), this really should be
> > the mode of type "int" which is usually SImode, but might be HImode
> > for some 16-bit targets.  This could avoid unnecessarily extending
> > the index to SImode and later only using the low 16 bits anyway on
> > such targets (AVR for example).
>
> We really should allow casehi/casedi instead of casesi, at least for
> consistancy in the naming scheme.  That would mean creating a case optab, etc.

  I second this motion as I have in my ARM tree a "caseqi" for the case
where the index is a single byte.  This gives me a very noticable speed up
on a number of byte code interpreter loops.  To implement this I needed to
apply the following patch to gcc/c-typeck.c to remove the forcing of the
index to SImode in addition to duplicating the casesi code in gcc/stmt.c
and of course adding a caseqi entry to gcc/config/arm/arm.md:

----------------------------------------------------------------------------
--- c-typeck.c  2000/11/20 19:06:17     1.105
+++ c-typeck.c  2000/11/30 04:19:43
@@ -6555,7 +6555,7 @@
              && (type == long_integer_type_node
                  || type == long_unsigned_type_node))
            warning ("`long' switch expression not converted to `int' in
ISO C");
-
+#if 0
          exp = default_conversion (exp);
          type = TREE_TYPE (exp);
          index = get_unwidened (exp, NULL_TREE);
@@ -6566,6 +6566,7 @@
          if (TREE_UNSIGNED (TREE_TYPE (exp))
              == TREE_UNSIGNED (TREE_TYPE (index)))
            exp = index;
+#endif
        }
     }
----------------------------------------------------------------------------

  The other issue with the case implementation that I have been thinking
about is being able to change the jump table from a table of addresses
(SI) to a table of pc offsets which can then be a smaller type such as
HI or even QI if the offsets are small enough.  But just getting a generic
method of handling casesi/casehi/caseqi/etc. would be nice ...

	Thanks,

		CraigN
--
      Craig Newell                email: CraigN@ieee.org
      Free Spirit                 icbm:  N 42°38'47" W 71°18'19"



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