This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
CSE fold_rtx subreg patch
- To: egcs-patches at cygnus dot com
- Subject: CSE fold_rtx subreg patch
- From: john at feith dot com (John Wehle)
- Date: Sat, 4 Jul 1998 00:36:10 -0400
This patch allows gcc to produce better assembly code in some situations
when configured for i386. For example:
unsigned char c;
int
func(unsigned char a)
{
unsigned char b;
b = a;
c = b;
return b;
}
compiles better with this patch installed.
ChangeLog:
Fri Jul 3 23:44:00 EDT 1998 John Wehle (john@feith.com)
* cse.c (fold_rtx): Try using an equivalent subreg if
it isn't more expensive than the current reg.
Enjoy!
-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/cse.c.ORIGINAL Wed Jul 1 11:01:14 1998
--- gcc/cse.c Fri Jul 3 23:40:39 1998
***************
*** 5197,5202 ****
--- 5197,5212 ----
switch (GET_CODE (arg))
{
case REG:
+ /* If the operand is equivalent to a SUBREG and the mode fits
+ within a word, then use the SUBREG. */
+ if (GET_MODE_SIZE (mode_arg) < UNITS_PER_WORD)
+ {
+ rtx y = lookup_as_function (arg, SUBREG);
+
+ if (y != 0 && COST (y) <= COST (arg))
+ folded_arg = copy_rtx (y);
+ }
+
/* This is the same as calling equiv_constant; it is duplicated
here for speed. */
if (REGNO_QTY_VALID_P (REGNO (arg))
***************
*** 5204,5210 ****
&& GET_CODE (qty_const[reg_qty[REGNO (arg)]]) != REG
&& GET_CODE (qty_const[reg_qty[REGNO (arg)]]) != PLUS)
const_arg
! = gen_lowpart_if_possible (GET_MODE (arg),
qty_const[reg_qty[REGNO (arg)]]);
break;
--- 5214,5220 ----
&& GET_CODE (qty_const[reg_qty[REGNO (arg)]]) != REG
&& GET_CODE (qty_const[reg_qty[REGNO (arg)]]) != PLUS)
const_arg
! = gen_lowpart_if_possible (mode_arg,
qty_const[reg_qty[REGNO (arg)]]);
break;
***************
*** 5273,5279 ****
replacements[0] = cheap_arg, replacements[1] = expensive_arg;
for (j = 0;
j < 2 && replacements[j]
! && COST (replacements[j]) < COST (XEXP (x, i));
j++)
{
if (validate_change (insn, &XEXP (x, i), replacements[j], 0))
--- 5283,5289 ----
replacements[0] = cheap_arg, replacements[1] = expensive_arg;
for (j = 0;
j < 2 && replacements[j]
! && COST (replacements[j]) <= COST (XEXP (x, i));
j++)
{
if (validate_change (insn, &XEXP (x, i), replacements[j], 0))
-------------------------------------------------------------------------
| Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com |
| John Wehle | Fax: 1-215-540-5495 | |
-------------------------------------------------------------------------