casesi with HImode index
Marek Michalkiewicz
marekm@linux.org.pl
Wed Nov 29 09:29:00 GMT 2000
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).
Bootstrapped on x86. Should have no effect right now because all
targets that have "casesi" have its operand 0 of mode SImode.
2000-11-29 Marek Michalkiewicz <marekm@linux.org.pl>
* stmt.c (expand_end_case): Convert the index to the mode of
"casesi" operand 0, do not assume it is always SImode.
diff -rc3p orig/egcs/gcc/stmt.c egcs/gcc/stmt.c
*** orig/egcs/gcc/stmt.c Fri Nov 17 18:45:12 2000
--- egcs/gcc/stmt.c Wed Nov 29 17:37:37 2000
*************** expand_end_case (orig_index)
*** 5524,5535 ****
#ifdef HAVE_casesi
if (HAVE_casesi)
{
! enum machine_mode index_mode = SImode;
int index_bits = GET_MODE_BITSIZE (index_mode);
rtx op1, op2;
enum machine_mode op_mode;
! /* Convert the index to SImode. */
if (GET_MODE_BITSIZE (TYPE_MODE (index_type))
> GET_MODE_BITSIZE (index_mode))
{
--- 5524,5537 ----
#ifdef HAVE_casesi
if (HAVE_casesi)
{
! enum machine_mode index_mode =
! insn_data[(int) CODE_FOR_casesi].operand[0].mode;
int index_bits = GET_MODE_BITSIZE (index_mode);
rtx op1, op2;
enum machine_mode op_mode;
! /* Convert the index to the mode specified for operand 0
! in the RTL template of "casesi" (usually SImode). */
if (GET_MODE_BITSIZE (TYPE_MODE (index_type))
> GET_MODE_BITSIZE (index_mode))
{
*************** expand_end_case (orig_index)
*** 5561,5567 ****
index = protect_from_queue (index, 0);
do_pending_stack_adjust ();
! op_mode = insn_data[(int) CODE_FOR_casesi].operand[0].mode;
if (! (*insn_data[(int) CODE_FOR_casesi].operand[0].predicate)
(index, op_mode))
index = copy_to_mode_reg (op_mode, index);
--- 5563,5569 ----
index = protect_from_queue (index, 0);
do_pending_stack_adjust ();
! op_mode = index_mode;
if (! (*insn_data[(int) CODE_FOR_casesi].operand[0].predicate)
(index, op_mode))
index = copy_to_mode_reg (op_mode, index);
More information about the Gcc-patches
mailing list