This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] fix address_cost for x86
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 4 Jul 2007 13:29:07 +0200
- Subject: [patch] fix address_cost for x86
Hello,
ix86_address_cost considers offsetted addressing modes cheaper than
the modes without offset. Ivopts thus try to introduce offsets to addresses
whenever it is possible, even in cases it does not give any gain.
This may result in larger code, or losing debug information (PR 32445).
The motivation for this behavior used to be that this encouraged cse to
create complex addressing modes, thus possibly eliminating some
computations. However, at the moment the only pass (except for ivopts)
that looks at address_cost is fwprop; and fwprop:should_replace_address
prefers more complex addressing modes even if their cost is the same
as the cost of a simpler addressing mode. Therefore, changing the
behavior of ix86_address_cost will not affect anything there.
The patch below (that makes the cost of complex addressing modes
the same as the cost of the simple ones) is performance neutral
on both i686 and x86_x64 for spec2000. It was bootstrapped & regtested
on i686.
Zdenek
* config/i386/i386.c (ix86_address_cost): Do not consider more complex
addressing modes cheaper.
Index: config/i386/i386.c
===================================================================
*** config/i386/i386.c (revision 126166)
--- config/i386/i386.c (working copy)
*************** ix86_address_cost (rtx x)
*** 6564,6575 ****
if (parts.index && GET_CODE (parts.index) == SUBREG)
parts.index = SUBREG_REG (parts.index);
- /* More complex memory references are better. */
- if (parts.disp && parts.disp != const0_rtx)
- cost--;
- if (parts.seg != SEG_DEFAULT)
- cost--;
-
/* Attempt to minimize number of registers in the address. */
if ((parts.base
&& (!REG_P (parts.base) || REGNO (parts.base) >= FIRST_PSEUDO_REGISTER))
--- 6564,6569 ----