This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
genrecog.c tweak
- To: gcc-patches at gcc dot gnu dot org
- Subject: genrecog.c tweak
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Date: Fri, 18 May 01 16:59:06 EDT
This un-pessimizes the recent change to genrecog.c in that it only avoids
using a switch for a HOST_WIDE_INT value if the actual integer is too large.
Tested (along with the previous patch) on alphaev6.
Fri May 18 07:26:34 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* genrecog.c (enum decision_type): Add DT_elt_zero-wide_safe.
(add_to_sequence): Make that decision type.
(maybe_both_true_2, nodes_identical_1, factor_tests): Use it.
(write_switch, write_cond, debug_decision_2): Likewise.
*** genrecog.c 2001/05/09 10:06:20 1.97
--- genrecog.c 2001/05/18 20:49:35
*************** struct decision_test
*** 85,94 ****
/* These types are roughly in the order in which we'd like to test them. */
! enum decision_type {
! DT_mode, DT_code, DT_veclen,
! DT_elt_zero_int, DT_elt_one_int, DT_elt_zero_wide,
! DT_veclen_ge, DT_dup, DT_pred, DT_c_test,
! DT_accept_op, DT_accept_insn
! } type;
union
--- 85,95 ----
/* These types are roughly in the order in which we'd like to test them. */
! enum decision_type
! {
! DT_mode, DT_code, DT_veclen,
! DT_elt_zero_int, DT_elt_one_int, DT_elt_zero_wide, DT_elt_zero_wide_safe,
! DT_veclen_ge, DT_dup, DT_pred, DT_c_test,
! DT_accept_op, DT_accept_insn
! } type;
union
*************** add_to_sequence (pattern, last, position
*** 957,964 ****
else if (fmt[i] == 'w')
{
if (i != 0)
abort ();
! test = new_decision_test (DT_elt_zero_wide, &place);
test->u.intval = XWINT (pattern, i);
}
--- 958,971 ----
else if (fmt[i] == 'w')
{
+ /* If this value actually fits in an int, we can use a switch
+ statement here, so indicate that. */
+ enum decision_type type
+ = ((int) XWINT (pattern, i) == XWINT (pattern, i))
+ ? DT_elt_zero_wide_safe : DT_elt_zero_wide;
+
if (i != 0)
abort ();
! test = new_decision_test (type, &place);
test->u.intval = XWINT (pattern, i);
}
*************** maybe_both_true_2 (d1, d2)
*** 1056,1059 ****
--- 1063,1067 ----
case DT_elt_one_int:
case DT_elt_zero_wide:
+ case DT_elt_zero_wide_safe:
return d1->u.intval == d2->u.intval;
*************** nodes_identical_1 (d1, d2)
*** 1279,1282 ****
--- 1287,1291 ----
case DT_elt_one_int:
case DT_elt_zero_wide:
+ case DT_elt_zero_wide_safe:
return d1->u.intval == d2->u.intval;
*************** factor_tests (head)
*** 1489,1493 ****
&& type != DT_elt_zero_int
&& type != DT_elt_one_int
! && type != DT_elt_zero_wide)
continue;
--- 1498,1502 ----
&& type != DT_elt_zero_int
&& type != DT_elt_one_int
! && type != DT_elt_zero_wide_safe)
continue;
*************** write_switch (start, depth)
*** 1859,1868 ****
|| type == DT_elt_zero_int
|| type == DT_elt_one_int
! || type == DT_elt_zero_wide)
{
- /* The argument is casted to int. In case HOST_WIDE_INT is more exact,
- we can't safely construct switch statement over it. */
- if (type == DT_elt_zero_wide && HOST_BITS_PER_WIDE_INT > sizeof (int) * CHAR_BIT)
- return p;
printf (" switch (");
switch (type)
--- 1868,1873 ----
|| type == DT_elt_zero_int
|| type == DT_elt_one_int
! || type == DT_elt_zero_wide_safe)
{
printf (" switch (");
switch (type)
*************** write_switch (start, depth)
*** 1880,1884 ****
printf ("XINT (x%d, 1)", depth);
break;
! case DT_elt_zero_wide:
/* Convert result of XWINT to int for portability since some C
compilers won't do it and some will. */
--- 1885,1889 ----
printf ("XINT (x%d, 1)", depth);
break;
! case DT_elt_zero_wide_safe:
/* Convert result of XWINT to int for portability since some C
compilers won't do it and some will. */
*************** write_switch (start, depth)
*** 1915,1918 ****
--- 1920,1924 ----
case DT_elt_one_int:
case DT_elt_zero_wide:
+ case DT_elt_zero_wide_safe:
printf (HOST_WIDE_INT_PRINT_DEC, p->tests->u.intval);
break;
*************** write_cond (p, depth, subroutine_type)
*** 1971,1974 ****
--- 1977,1981 ----
case DT_elt_zero_wide:
+ case DT_elt_zero_wide_safe:
printf ("XWINT (x%d, 0) == ", depth);
printf (HOST_WIDE_INT_PRINT_DEC, p->u.intval);
*************** debug_decision_2 (test)
*** 2741,2744 ****
--- 2748,2755 ----
case DT_elt_zero_wide:
fprintf (stderr, "elt0_w=");
+ fprintf (stderr, HOST_WIDE_INT_PRINT_DEC, test->u.intval);
+ break;
+ case DT_elt_zero_wide_safe:
+ fprintf (stderr, "elt0_ws=");
fprintf (stderr, HOST_WIDE_INT_PRINT_DEC, test->u.intval);
break;