[RFC] patch: Re: reg+reg addressing mode on SPARC
Dan Nicolaescu
dann@ics.uci.edu
Fri Aug 10 18:46:00 GMT 2001
Joe Buck <jbuck@synopsys.com> writes:
> Dan Nicolaescu writes:
> > Here is the result that I get for the code from the 2340 bug report
> > using a version of gcc patched to have ADDRESS_COST 2 for the reg+reg
> > addressing modes and 1 for all the other cases:
> >
> > ./a.out
> > test absolute additions ratio with
> > number time per second test0
> >
> > 0 0.31sec 161.29M 1.00
> > 1 0.31sec 161.29M 1.00
> [ all others are one as well ]
>
> Cool.
>
> Hmm. Seems the next step is to try your patch on other benchmarks, such
> as Spec-[year of your choice].
I will try it on Spec95.
Meanwhile let's see if my patch is correct...
(it bootstraps on sparc-sun-solaris2.8)
Can somebody that knows this stuff please look at the
sparc_address_cost function and see if it detects correctly the reg+reg
addressing mode?
2001-08-10 Dan Nicolaescu <dann@ics.uci.edu>
* config/sparc/sparc.c (sparc_address_cost): New function to
compute the address mode cost.
* config/sparc/sparc.h (ADDRESS_COST): Use it.
* config/sparc/sparc-protos.h (sparc_address_cost): New prototype.
*** sparc.h~ Sun May 13 00:10:12 2001
--- sparc.h Fri Aug 10 14:46:56 2001
***************
*** 2852,2858 ****
return 0; \
return 8;
! #define ADDRESS_COST(RTX) 1
/* Compute extra cost of moving data between one register class
and another. */
--- 2852,2858 ----
return 0; \
return 8;
! #define ADDRESS_COST(RTX) sparc_address_cost(RTX)
/* Compute extra cost of moving data between one register class
and another. */
*** sparc-protos.h~ Fri Aug 10 14:48:14 2001
--- sparc-protos.h Fri Aug 10 18:13:12 2001
***************
*** 24,31 ****
#ifndef __SPARC_PROTOS_H__
#define __SPARC_PROTOS_H__
- extern int sparc_address_cost PARAMS ((rtx));
-
#ifdef TREE_CODE
extern struct rtx_def *function_value PARAMS ((tree, enum machine_mode, int));
extern void function_arg_advance PARAMS ((CUMULATIVE_ARGS *,
--- 24,29 ----
***************
*** 77,82 ****
--- 75,81 ----
unsigned int, unsigned long,
unsigned long, const char *,
const char *, unsigned long));
+ extern int sparc_address_cost PARAMS ((rtx));
#ifdef RTX_CODE
extern enum machine_mode select_cc_mode PARAMS ((enum rtx_code, rtx, rtx));
*** sparc.c~ Sun May 13 00:10:12 2001
--- sparc.c Fri Aug 10 18:07:56 2001
***************
*** 8606,8611 ****
--- 8606,8634 ----
ggc_mark_rtx (ups->group[i]);
}
+ /* Compute the cost of an addressing mode.
+ Just consider reg+reg more expensive. */
+
+ int
+ sparc_address_cost (addr)
+ rtx addr;
+ {
+ if (GET_CODE (addr) == REG)
+ return 1;
+
+ if (GET_CODE (addr) == PLUS)
+ {
+ rtx op0 = XEXP (addr, 0);
+ rtx op1 = XEXP (addr, 1);
+ enum rtx_code code0 = GET_CODE (op0);
+ enum rtx_code code1 = GET_CODE (op1);
+ if (code0 == REG || code1 == REG)
+ return 2;
+ return 1;
+ }
+ return 1;
+ }
+
/* Called to register all of our global variables with the garbage
collector. */
More information about the Gcc
mailing list