[patch] h8300.c: Make shifts leave valid cc0.
Kazu Hirata
kazu@cs.umass.edu
Sun Dec 22 07:02:00 GMT 2002
Hi,
Attached is a patch to make shifts leave valid cc0.
For example, without the patch, lshiftrt:HI by 8 bits is expressed as
mov.b r3h,r3l
sub.b r3h,r3h
whereas with the patch,
mov.b r3h,r3l
extu.w r3
which leaves valid cc0, making it useful when a branch instruction is
to follow.
This patch itself does not express the validity of cc0. It will be
addressed in a separate patch.
Tested on h8300 port. Committed.
Kazu Hirata
2002-12-22 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.c (get_shift_alg): Make shift insn
sequences end with a valid cc0 whenever possible.
Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.180
diff -c -r1.180 h8300.c
*** h8300.c 21 Dec 2002 17:43:14 -0000 1.180
--- h8300.c 22 Dec 2002 14:47:27 -0000
***************
*** 2590,2610 ****
{
case SHIFT_ASHIFT:
info->special = "mov.b\t%s0,%t0\n\tsub.b\t%s0,%s0";
- info->shift1 = "shal.b\t%t0";
- info->shift2 = "shal.b\t#2,%t0";
goto end;
case SHIFT_LSHIFTRT:
! info->special = "mov.b\t%t0,%s0\n\tsub.b\t%t0,%t0";
! info->shift1 = "shlr.b\t%s0";
! info->shift2 = "shlr.b\t#2,%s0";
goto end;
case SHIFT_ASHIFTRT:
if (TARGET_H8300)
! info->special = "mov.b\t%t0,%s0\n\tbld\t#7,%s0\n\tsubx\t%t0,%t0";
else
! info->special = "mov.b\t%t0,%s0\n\texts.w\t%T0";
! info->shift1 = "shar.b\t%s0";
! info->shift2 = "shar.b\t#2,%s0";
goto end;
}
}
--- 2590,2618 ----
{
case SHIFT_ASHIFT:
info->special = "mov.b\t%s0,%t0\n\tsub.b\t%s0,%s0";
goto end;
case SHIFT_LSHIFTRT:
! if (TARGET_H8300)
! {
! info->special = "mov.b\t%t0,%s0\n\tsub.b\t%t0,%t0";
! info->shift1 = "shlr.b\t%s0";
! }
! else
! {
! info->special = "mov.b\t%t0,%s0\n\textu.w\t%T0";
! }
goto end;
case SHIFT_ASHIFTRT:
if (TARGET_H8300)
! {
! info->special = "mov.b\t%t0,%s0\n\tbld\t#7,%s0\n\tsubx\t%t0,%t0";
! info->shift1 = "shar.b\t%s0";
! info->shift2 = "shar.b\t#2,%s0";
! }
else
! {
! info->special = "mov.b\t%t0,%s0\n\texts.w\t%T0";
! }
goto end;
}
}
***************
*** 2730,2744 ****
}
goto end;
case SHIFT_LSHIFTRT:
- info->special = "mov.w\t%e0,%f0\n\tsub.w\t%e0,%e0";
if (TARGET_H8300)
{
! info->shift1 = "shlr\t%x0\n\trotxr\t%w0";
}
else
{
! info->shift1 = "shlr.l\t%S0";
! info->shift2 = "shlr.l\t#2,%S0";
}
goto end;
case SHIFT_ASHIFTRT:
--- 2738,2751 ----
}
goto end;
case SHIFT_LSHIFTRT:
if (TARGET_H8300)
{
! info->special = "mov.w\t%e0,%f0\n\tsub.w\t%e0,%e0";
! info->shift1 = "shlr\t%x0\n\trotxr\t%w0";
}
else
{
! info->special = "mov.w\t%e0,%f0\n\textu.l\t%S0";
}
goto end;
case SHIFT_ASHIFTRT:
***************
*** 2750,2757 ****
else
{
info->special = "mov.w\t%e0,%f0\n\texts.l\t%S0";
- info->shift1 = "shar.l\t%S0";
- info->shift2 = "shar.l\t#2,%S0";
}
goto end;
}
--- 2757,2762 ----
***************
*** 2814,2822 ****
goto end;
case SHIFT_LSHIFTRT:
if (TARGET_H8300H)
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\tsub.w\t%e0,%e0";
else
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t#2,%S0\n\trotl.l\t#2,%S0\n\tsub.w\t%e0,%e0";
info->shift1 = "";
info->shift2 = "";
goto end;
--- 2819,2827 ----
goto end;
case SHIFT_LSHIFTRT:
if (TARGET_H8300H)
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\textu.l\t%S0";
else
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t#2,%S0\n\trotl.l\t#2,%S0\n\textu.l\t%S0";
info->shift1 = "";
info->shift2 = "";
goto end;
***************
*** 2838,2846 ****
goto end;
case SHIFT_LSHIFTRT:
if (TARGET_H8300H)
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\tsub.w\t%e0,%e0";
else
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t#2,%S0\n\trotl.l\t%S0\n\tsub.w\t%e0,%e0";
info->shift1 = "";
info->shift2 = "";
goto end;
--- 2843,2851 ----
goto end;
case SHIFT_LSHIFTRT:
if (TARGET_H8300H)
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\textu.l\t%S0";
else
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t#2,%S0\n\trotl.l\t%S0\n\textu.l\t%S0";
info->shift1 = "";
info->shift2 = "";
goto end;
***************
*** 2862,2870 ****
goto end;
case SHIFT_LSHIFTRT:
if (TARGET_H8300H)
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\tsub.w\t%e0,%e0";
else
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t#2,%S0\n\tsub.w\t%e0,%e0";
info->shift1 = "";
info->shift2 = "";
goto end;
--- 2867,2875 ----
goto end;
case SHIFT_LSHIFTRT:
if (TARGET_H8300H)
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t%S0\n\trotl.l\t%S0\n\textu.l\t%S0";
else
! info->special = "sub.w\t%f0,%f0\n\trotl.l\t#2,%S0\n\textu.l\t%S0";
info->shift1 = "";
info->shift2 = "";
goto end;
***************
*** 2900,2906 ****
info->special = "shll.l\t%S0\n\txor.l\t%S0,%S0\n\trotxl.l\t%S0";
goto end;
case SHIFT_ASHIFTRT:
! info->special = "shll\t%e0\n\tsubx\t%w0,%w0\n\tmov.b\t%w0,%x0\n\tmov.w\t%f0,%e0";
goto end;
}
}
--- 2905,2911 ----
info->special = "shll.l\t%S0\n\txor.l\t%S0,%S0\n\trotxl.l\t%S0";
goto end;
case SHIFT_ASHIFTRT:
! info->special = "shll\t%e0\n\tsubx\t%w0,%w0\n\texts.w\t%T0\n\texts.l\t%S0";
goto end;
}
}
More information about the Gcc-patches
mailing list