This is the mail archive of the
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
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
* config/i386/i386.c (ix86_address_cost): Do not consider more complex
addressing modes cheaper.
*** 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)
- if (parts.seg != SEG_DEFAULT)
/* Attempt to minimize number of registers in the address. */
&& (!REG_P (parts.base) || REGNO (parts.base) >= FIRST_PSEUDO_REGISTER))
--- 6564,6569 ----