This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR target/65103, 1/3] Fix cost of PIC register in ix86_address_cost
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Ilya Enkovich <enkovich dot gnu at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 10 Mar 2015 16:17:20 +0100
- Subject: Re: [PATCH, PR target/65103, 1/3] Fix cost of PIC register in ix86_address_cost
- Authentication-results: sourceware.org; auth=none
- References: <20150310145446 dot GB27860 at msticlxl57 dot ims dot intel dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Mar 10, 2015 at 05:54:46PM +0300, Ilya Enkovich wrote:
> This patches set addresses the problem of inefficient usage of x86 addressing modes in PIC. Looking into generated 32bit PIC assembler we may see lots of 'leal <symbol>@GOTOFF, %reg' instructions. Almost in all cases this constant value may be propagated into following address operand, but it doesn't happen for various reasons.
>
> I scanned assembler generated for SPEC2000 on O2 and Ofast + LTO to measure patches effect. Here are results for the whole patches set:
>
> Test O2 ref patched Ofast + LTO ref patched
> 164.gzip 12 0 (-100%) 39 0 (-100%)
> 175.vpr 0 0 (-0%) 4 0 (-100%)
> 176.gcc 141 6 (-96%) 294 10 (-97%)
> 181.mcf 4 0 (-100%) 4 2 (-50%)
...
The 0s and -100% look very suspicious to me.
> 2015-03-10 Ilya Enkovich <ilya.enkovich@intel.com>
>
> PR target/65103
> * gcc/config/i386/i386.c (ix86_address_cost): Fix cost of a PIC
> register.
Avoid the gcc/ prefix in the ChangeLog entry.
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr65103-1.c
> @@ -0,0 +1,18 @@
> +/* { dg-do compile { target ia32 } } */
> +/* { dg-options "-m32 -O2 -fPIE" } */
No -m32 in dg-options please. As the test is guarded with
ia32, there is no need for that either.
But -fPIE needs to be guarded too by effective target pie.
> +/* { dg-final { scan-assembler-not "GOTOFF," } } */
> +
> +typedef struct S
> +{
> + int a;
> + int sum;
> + int delta;
> +} S;
> +
> +S gs;
> +int global_opt (int max)
> +{
> + while (gs.sum < max)
> + gs.sum += gs.delta;
> + return gs.a;
> +}
Jakub