This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Improve ix86 machine reorg (PR target/39942, take 2, part 1)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jan Hubicka <jh at suse dot cz>, "H.J. Lu" <hjl dot tools at gmail dot com>, Uros Bizjak <ubizjak at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 13 May 2009 10:34:31 +0200
- Subject: [PATCH] Improve ix86 machine reorg (PR target/39942, take 2, part 1)
- References: <20090430114639.GU5781@tyan-ft48-01.lab.bos.redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
On Thu, Apr 30, 2009 at 01:46:39PM +0200, Jakub Jelinek wrote:
> This patch kills some IMHO completely unnecessary paddings and
> decreases others, added for TARGET_FOUR_JUMP_LIMIT optimization
> during ix86 machine reorg.
>
> There are actually 2 parts of the patch. One, the x86-64.h/linux.h
> change fixes the ASM_OUTPUT_MAX_SKIP_ALIGN macros so that they never
> skip more than MAX_SKIP bytes. Normally for labels max_skip is hardcoded
> from the backend based on -mtune, so the align, max_skip pairs can be
> 4,,7 or 4,,10 or 4,,15, but for the paddings added by
> TARGET_FOUR_JUMP_LIMIT optimization max_skip can be anything from 1 through
> 10 or so.
> If we emit
> .p2align 4,,2
> .p2align 3
> into the assembly, because we want to skip at most 2 bytes, then
> this can skip up to 7 bytes. In fact, for the "skip" instruction we
> don't want to ever emit the second .p2align, but I think the 4 jumps
> alignments >= 7 are rare enough that it is not worth introducing new
> macros for it.
I'm now sending just this part separated for easier review, as it is
independent and on its own saves ~ 2% of code size for -O2 x86-64 or i?86
code. Bootstrapped/regtested many times on trunk as well as 4.4 branch,
ok for trunk?
2009-05-13 Jakub Jelinek <jakub@redhat.com>
PR target/39942
* config/i386/x86-64.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Don't emit second
.p2align 3 if MAX_SKIP is smaller than 7.
* config/i386/linux.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise.
--- gcc/config/i386/x86-64.h.jj 2009-05-05 08:33:20.000000000 +0200
+++ gcc/config/i386/x86-64.h 2009-05-05 16:37:13.000000000 +0200
@@ -74,7 +74,9 @@ see the files COPYING3 and COPYING.RUNTI
fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
/* Make sure that we have at least 8 byte alignment if > 8 byte \
alignment is preferred. */ \
- if ((LOG) > 3 && (1 << (LOG)) > ((MAX_SKIP) + 1)) \
+ if ((LOG) > 3 \
+ && (1 << (LOG)) > ((MAX_SKIP) + 1) \
+ && (MAX_SKIP) >= 7) \
fprintf ((FILE), "\t.p2align 3\n"); \
} \
} \
--- gcc/config/i386/linux.h.jj 2009-05-05 08:33:20.000000000 +0200
+++ gcc/config/i386/linux.h 2009-05-05 16:37:13.000000000 +0200
@@ -1,6 +1,6 @@
/* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
- 2006, 2007, 2008 Free Software Foundation, Inc.
+ 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by Eric Youngdale.
Modified for stabs-in-ELF by H.J. Lu.
@@ -153,7 +153,9 @@ along with GCC; see the file COPYING3.
fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
/* Make sure that we have at least 8 byte alignment if > 8 byte \
alignment is preferred. */ \
- if ((LOG) > 3 && (1 << (LOG)) > ((MAX_SKIP) + 1)) \
+ if ((LOG) > 3 \
+ && (1 << (LOG)) > ((MAX_SKIP) + 1) \
+ && (MAX_SKIP) >= 7) \
fprintf ((FILE), "\t.p2align 3\n"); \
} \
} \
Jakub