From: Michael Hayes Date: Sat, 17 Apr 1999 22:27:41 +0000 (+0000) Subject: c4x.c (legitimize_operands): Use rtx_cost to determine if it is worthwhile forcing... X-Git-Tag: prereleases/gcc-2.95-test~869 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87ba694401df1d06dda4b8c14b50528a740eef6d;p=thirdparty%2Fgcc.git c4x.c (legitimize_operands): Use rtx_cost to determine if it is worthwhile forcing a constant into a register. * config/c4x/c4x.c (legitimize_operands): Use rtx_cost to determine if it is worthwhile forcing a constant into a register. * config/c4x/c4x.h (CONST_COSTS): An integer value of 255 or 65535 used with a logical and or an integer value of 16 or 24 used with a right shift has zero cost on the C40. From-SVN: r26529 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0ae98a6110f2..9411c209b2f1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +Sun Apr 18 17:24:10 1999 Michael Hayes + + * config/c4x/c4x.c (legitimize_operands): Use rtx_cost + to determine if it is worthwhile forcing a constant into a register. + * config/c4x/c4x.h (CONST_COSTS): An integer value of 255 or 65535 + used with a logical and or an integer value of 16 or 24 used with + a right shift has zero cost on the C40. + Sat Apr 17 21:30:11 1999 Bernd Schmidt * gcse.c (compute_local_properties): If setp is nonzero, clear diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c index 0b84e02826e6..5c5690a4eaf9 100644 --- a/gcc/config/c4x/c4x.c +++ b/gcc/config/c4x/c4x.c @@ -3582,6 +3582,11 @@ c4x_valid_operands (code, operands, mode, force) /* Any valid memory operand screened by src_operand is OK. */ case MEM: +#if 0 + if (code2 != REG) + return 0; +#endif + break; /* After CSE, any remaining (ADDRESSOF:P reg) gets converted into a stack slot memory address comprising a PLUS and a @@ -3644,10 +3649,9 @@ legitimize_operands (code, operands, mode) if (! reload_in_progress && TARGET_HOIST && optimize > 0 - && ((GET_CODE (operands[1]) == CONST_INT - && ! c4x_J_constant (operands[1]) - && INTVAL (operands[1]) != 0) - || GET_CODE (operands[1]) == CONST_DOUBLE)) + && GET_CODE (operands[1]) == CONST_INT + && preserve_subexpressions_p () + && rtx_cost (operands[1], code) > 1) operands[1] = force_reg (mode, operands[1]); if (! reload_in_progress @@ -3661,11 +3665,11 @@ legitimize_operands (code, operands, mode) opportunities. */ if (! reload_in_progress && ! ((code == PLUS || code == MINUS) && mode == Pmode) - && (TARGET_HOIST && optimize > 1 - && ((GET_CODE (operands[2]) == CONST_INT - && ! c4x_J_constant (operands[2]) - && INTVAL (operands[2]) != 0) - || GET_CODE (operands[2]) == CONST_DOUBLE))) + && TARGET_HOIST + && optimize > 1 + && GET_CODE (operands[2]) == CONST_INT + && preserve_subexpressions_p () + && rtx_cost (operands[2], code) > 1) operands[2] = force_reg (mode, operands[2]); /* We can get better code on a C30 if we force constant shift counts diff --git a/gcc/config/c4x/c4x.h b/gcc/config/c4x/c4x.h index 67ac4a0cd873..1dc8d5c63ed7 100644 --- a/gcc/config/c4x/c4x.h +++ b/gcc/config/c4x/c4x.h @@ -1763,7 +1763,13 @@ extern void c4x_encode_section_info (); Some small integers are effectively free for the C40. We should also consider if we are using the small memory model. With the big memory model we require an extra insn for a constant - loaded from memory. */ + loaded from memory. + + This is used by expand_binop to decide whether to force a constant + into a register. If the cost is greater than 2 and the constant + is used within a short loop, it gets forced into a register. + Ideally, there should be some weighting as to how mnay times it is used + within the loop. */ #define SHIFT_CODE_P(C) ((C) == ASHIFT || (C) == ASHIFTRT || (C) == LSHIFTRT) @@ -1776,6 +1782,16 @@ extern void c4x_encode_section_info (); case CONST_INT: \ if (c4x_J_constant (RTX)) \ return 0; \ + if (! TARGET_C3X \ + && OUTER_CODE == AND \ + && GET_CODE (RTX) == CONST_INT \ + && (INTVAL (RTX) == 255 || INTVAL (RTX) == 65535)) \ + return 0; \ + if (! TARGET_C3X \ + && (OUTER_CODE == ASHIFTRT || OUTER_CODE == LSHIFTRT) \ + && GET_CODE (RTX) == CONST_INT \ + && (INTVAL (RTX) == 16 || INTVAL (RTX) == 24)) \ + return 0; \ if (TARGET_C3X && SHIFT_CODE_P (OUTER_CODE)) \ return 3; \ if (LOGICAL_CODE_P (OUTER_CODE) \