Re: [PATCH 2/3] Temporary remove "at least 8 byte alignment" code from x86
On 06/13/2018 04:02 AM, Jeff Law wrote: On 05/21/2018 07:55 AM, marxin wrote: gcc/ChangeLog: 2017-04-18 Denys Vlasenko * config/i386/i386-common.c (ix86_handle_option): Remove support for obsolete -malign-loops, -malign-jumps and -malign-functions options. * config/i386/i386.opt: Likewise. The ChangeLog doesn't seem match the actual changes. I think this patch is more about using the additional info that's potentially provided by the -falign options to drive backend decisions and dropping the secondary alignment request. Hi. Exactly. The change seems to consistently do: (1<<(LOG)))-1) Which needs some horizontal whitespace. Fixed in updated version of the patch. Martin The meat of the changes seem fairly reasonable. jeff >From d4e3c9f6438dd665a5e1802c625dbbd7742cb52f Mon Sep 17 00:00:00 2001 From: marxin Date: Mon, 21 May 2018 15:55:09 +0200 Subject: [PATCH] Temporary remove "at least 8 byte alignment" code from x86 gcc/ChangeLog: 2017-04-18 Denys Vlasenko * config/i386/dragonfly.h: (ASM_OUTPUT_MAX_SKIP_ALIGN): Use a simpler align directive also if MAXSKIP = ALIGN-1. * config/i386/gas.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/lynx.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/netbsd-elf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/i386.h (ASM_OUTPUT_MAX_SKIP_PAD): Likewise. * config/i386/freebsd.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Remove "If N is large, do at least 8 byte alignment" code. Add SUBALIGN_LOG define. Use a simpler align directive also if MAXSKIP = ALIGN-1. * config/i386/gnu-user.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/iamcu.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/openbsdelf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/x86-64.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. --- gcc/config/i386/dragonfly.h | 10 ++ gcc/config/i386/freebsd.h| 16 +--- gcc/config/i386/gas.h| 12 +++- gcc/config/i386/gnu-user.h | 16 +--- gcc/config/i386/i386.h | 2 +- gcc/config/i386/iamcu.h | 16 +--- gcc/config/i386/lynx.h | 6 -- gcc/config/i386/netbsd-elf.h | 6 -- gcc/config/i386/openbsdelf.h | 16 +--- gcc/config/i386/x86-64.h | 16 ++-- 10 files changed, 48 insertions(+), 68 deletions(-) diff --git a/gcc/config/i386/dragonfly.h b/gcc/config/i386/dragonfly.h index a05b36435de..40774c0cf7a 100644 --- a/gcc/config/i386/dragonfly.h +++ b/gcc/config/i386/dragonfly.h @@ -69,10 +69,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN #undef ASM_OUTPUT_MAX_SKIP_ALIGN -#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ - if ((LOG) != 0) { \ -if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ -else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ + if ((LOG) != 0) { \ +if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1 << (LOG)) - 1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ +else\ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ } #endif diff --git a/gcc/config/i386/freebsd.h b/gcc/config/i386/freebsd.h index 0f38e6d859a..caac6b38575 100644 --- a/gcc/config/i386/freebsd.h +++ b/gcc/config/i386/freebsd.h @@ -92,25 +92,19 @@ along with GCC; see the file COPYING3. If not see /* A C statement to output to the stdio stream FILE an assembler command to advance the location counter to a multiple of 1<= (1 << (LOG)) - 1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else\ 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)\ - && (MAX_SKIP) >= 7) \ - fputs ("\t.p2align 3\n", (FILE));\ - } \ } \ } while (0) #endif diff --git a/gcc/config/i386/gas.h b/gcc/config/i386/gas.h index 25d5f7809b5..e149ab1360c 100644 --- a/gcc/config/i386/gas.h +++ b/gcc/config/i386/gas.h @@ -57,7 +57,7 @@ along with GCC; see the file COPYING3. If not see #ifdef HAVE_GAS_BALIGN_AND_P2ALIGN #undef ASM_OUTPUT_ALIGN #define ASM_OUTPUT_ALIGN(FILE,LOG) \ - if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG)) + if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1 << (LOG)) #endif /* A C statement to output to the stdio stream FILE an assembler @@ -68,10 +68,12 @@ along with GCC; see the file COPYING3. If not see #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN # define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ - if ((LOG) != 0) {\ - if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ - else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ - } +if ((LOG) != 0
Re: [PATCH 2/3] Temporary remove "at least 8 byte alignment" code from x86
On 05/21/2018 07:55 AM, marxin wrote: > > gcc/ChangeLog: > > 2017-04-18 Denys Vlasenko > > * config/i386/i386-common.c (ix86_handle_option): Remove support > for obsolete -malign-loops, -malign-jumps and -malign-functions > options. > * config/i386/i386.opt: Likewise. The ChangeLog doesn't seem match the actual changes. I think this patch is more about using the additional info that's potentially provided by the -falign options to drive backend decisions and dropping the secondary alignment request. The change seems to consistently do: (1<<(LOG)))-1) Which needs some horizontal whitespace. The meat of the changes seem fairly reasonable. jeff
[PATCH 2/3] Temporary remove "at least 8 byte alignment" code from x86
gcc/ChangeLog: 2017-04-18 Denys Vlasenko * config/i386/i386-common.c (ix86_handle_option): Remove support for obsolete -malign-loops, -malign-jumps and -malign-functions options. * config/i386/i386.opt: Likewise. --- gcc/config/i386/dragonfly.h | 10 ++ gcc/config/i386/freebsd.h| 16 +--- gcc/config/i386/gas.h| 10 ++ gcc/config/i386/gnu-user.h | 16 +--- gcc/config/i386/i386.h | 2 +- gcc/config/i386/iamcu.h | 16 +--- gcc/config/i386/lynx.h | 6 -- gcc/config/i386/netbsd-elf.h | 6 -- gcc/config/i386/openbsdelf.h | 16 +--- gcc/config/i386/x86-64.h | 16 ++-- 10 files changed, 47 insertions(+), 67 deletions(-) diff --git a/gcc/config/i386/dragonfly.h b/gcc/config/i386/dragonfly.h index a05b36435de..5432af9aa01 100644 --- a/gcc/config/i386/dragonfly.h +++ b/gcc/config/i386/dragonfly.h @@ -69,10 +69,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN #undef ASM_OUTPUT_MAX_SKIP_ALIGN -#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ - if ((LOG) != 0) { \ -if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ -else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ + if ((LOG) != 0) { \ +if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ +else\ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ } #endif diff --git a/gcc/config/i386/freebsd.h b/gcc/config/i386/freebsd.h index 0f38e6d859a..40f7a21dfd6 100644 --- a/gcc/config/i386/freebsd.h +++ b/gcc/config/i386/freebsd.h @@ -92,25 +92,19 @@ along with GCC; see the file COPYING3. If not see /* A C statement to output to the stdio stream FILE an assembler command to advance the location counter to a multiple of 1<= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else\ 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)\ - && (MAX_SKIP) >= 7) \ - fputs ("\t.p2align 3\n", (FILE));\ - } \ } \ } while (0) #endif diff --git a/gcc/config/i386/gas.h b/gcc/config/i386/gas.h index 25d5f7809b5..e86c10588b8 100644 --- a/gcc/config/i386/gas.h +++ b/gcc/config/i386/gas.h @@ -68,10 +68,12 @@ along with GCC; see the file COPYING3. If not see #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN # define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ - if ((LOG) != 0) {\ - if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ - else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ - } +if ((LOG) != 0) { \ + if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else\ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +} #endif /* A C statement or statements which output an assembler instruction diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h index d1dad685e72..7c4d40c2eae 100644 --- a/gcc/config/i386/gnu-user.h +++ b/gcc/config/i386/gnu-user.h @@ -95,24 +95,18 @@ along with GCC; see the file COPYING3. If not see /* A C statement to output to the stdio stream FILE an assembler command to advance the location counter to a multiple of 1<= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else\ 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)\ - && (MAX_SKIP) >= 7) \ - fputs ("\t.p2align 3\n", (FILE));\ - } \ } \ } while (0) #endif diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 6ee99d36207..2da01394478 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2220,7 +2220,7 @@ extern int const svr4_dbx_register_map[FIRST_PSEUDO_REGISTER]; #define ASM_OUTPUT_MAX_SKIP_PAD(FILE, LOG, MAX_SKIP) \ if ((LOG) != 0) \ { \ - if ((MAX_SKIP) == 0) \ + if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ else\ fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ diff --git a/gcc/config/i386/iamcu.h b/gcc/config/i386/iamcu.h index b30132f377a..07ecbec60d3 100644 --- a/gcc/config/i386/iamcu.h +++ b/gcc/config/i386/iamcu.h @@ -62,23 +62,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* A C stateme
[PATCH 2/3] Temporary remove "at least 8 byte alignment" code from x86
This change drops forced alignment to 8 if requested alignment is higher than 8: before the patch, -falign-functions=9 was generating .p2align 4,,8 .p2align 3 which means: "align to 16 if the skip is 8 bytes or less; else align to 8". After this change, ".p2align 3" is not emitted. This behavior will be implemented differently by the next patch. The new SUBALIGN_LOG define will be used by the next patch. While we are here, avoid generating ".p2align N,,2^N-1" - it is functionally equivalent to ".p2align N". In this case, use the latter. 2017-04-18 Denys Vlasenko * config/i386/dragonfly.h: (ASM_OUTPUT_MAX_SKIP_ALIGN): Use a simpler align directive also if MAXSKIP = ALIGN-1. * config/i386/gas.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/lynx.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/netbsd-elf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/i386.h (ASM_OUTPUT_MAX_SKIP_PAD): Likewise. * config/i386/freebsd.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Remove "If N is large, do at least 8 byte alignment" code. Add SUBALIGN_LOG define. Use a simpler align directive also if MAXSKIP = ALIGN-1. * config/i386/gnu-user.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/iamcu.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/openbsdelf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/x86-64.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. Index: gcc/config/i386/dragonfly.h === --- gcc/config/i386/dragonfly.h (revision 239860) +++ gcc/config/i386/dragonfly.h (working copy) @@ -69,10 +69,12 @@ see the files COPYING3 and COPYING.RUNTIME respect #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN #undef ASM_OUTPUT_MAX_SKIP_ALIGN -#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ - if ((LOG) != 0) { \ -if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ -else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ + if ((LOG) != 0) {\ +if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ +else \ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ } #endif Index: gcc/config/i386/freebsd.h === --- gcc/config/i386/freebsd.h (revision 239860) +++ gcc/config/i386/freebsd.h (working copy) @@ -92,9 +92,9 @@ along with GCC; see the file COPYING3. If not see /* A C statement to output to the stdio stream FILE an assembler command to advance the location counter to a multiple of 1<= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else \ 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) \ - && (MAX_SKIP) >= 7) \ - fputs ("\t.p2align 3\n", (FILE)); \ - } \ } \ } while (0) #endif Index: gcc/config/i386/gas.h === --- gcc/config/i386/gas.h (revision 239860) +++ gcc/config/i386/gas.h (working copy) @@ -72,10 +72,12 @@ along with GCC; see the file COPYING3. If not see #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN # define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ - if ((LOG) != 0) {\ - if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ - else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ - } +if ((LOG) != 0) { \ + if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else \ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +} #endif /* A C statement or statements which output an assembler instruction Index: gcc/config/i386/gnu-user.h === --- gcc/config/i386/gnu-user.h (revision 239860
[PATCH 2/3] Temporary remove "at least 8 byte alignment" code from x86
This change drops forced alignment to 8 if requested alignment is higher than 8: before the patch, -falign-functions=9 was generating .p2align 4,,8 .p2align 3 which means: "align to 16 if the skip is 8 bytes or less; else align to 8". After this change, ".p2align 3" is not emitted. This behavior will be implemented differently by the next patch. The new SUBALIGN_LOG define will be used by the next patch. While we are here, avoid generating ".p2align N,,2^N-1" - it is functionally equivalent to ".p2align N". In this case, use the latter. 2016-09-27 Denys Vlasenko * config/i386/dragonfly.h: (ASM_OUTPUT_MAX_SKIP_ALIGN): Use a simpler align directive also if MAXSKIP = ALIGN-1. * config/i386/gas.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/lynx.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/netbsd-elf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/i386.h (ASM_OUTPUT_MAX_SKIP_PAD): Likewise. * config/i386/freebsd.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Remove "If N is large, do at least 8 byte alignment" code. Add SUBALIGN_LOG define. Use a simpler align directive also if MAXSKIP = ALIGN-1. * config/i386/gnu-user.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/iamcu.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/openbsdelf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/x86-64.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. Index: gcc/config/i386/dragonfly.h === --- gcc/config/i386/dragonfly.h (revision 239860) +++ gcc/config/i386/dragonfly.h (working copy) @@ -69,10 +69,12 @@ see the files COPYING3 and COPYING.RUNTIME respect #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN #undef ASM_OUTPUT_MAX_SKIP_ALIGN -#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ - if ((LOG) != 0) { \ -if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ -else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ + if ((LOG) != 0) {\ +if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ +else \ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ } #endif Index: gcc/config/i386/freebsd.h === --- gcc/config/i386/freebsd.h (revision 239860) +++ gcc/config/i386/freebsd.h (working copy) @@ -92,9 +92,9 @@ along with GCC; see the file COPYING3. If not see /* A C statement to output to the stdio stream FILE an assembler command to advance the location counter to a multiple of 1<= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else \ 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) \ - && (MAX_SKIP) >= 7) \ - fputs ("\t.p2align 3\n", (FILE)); \ - } \ } \ } while (0) #endif Index: gcc/config/i386/gas.h === --- gcc/config/i386/gas.h (revision 239860) +++ gcc/config/i386/gas.h (working copy) @@ -72,10 +72,12 @@ along with GCC; see the file COPYING3. If not see #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN # define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ - if ((LOG) != 0) {\ - if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ - else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ - } +if ((LOG) != 0) { \ + if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else \ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +} #endif /* A C statement or statements which output an assembler instruction Index: gcc/config/i386/gnu-user.h === --- gcc/config/i386/gnu-user.h (revision 239860
[PATCH 2/3] Temporary remove "at least 8 byte alignment" code from x86
This change drops forced alignment to 8 if requested alignment is higher than 8: before the patch, -falign-functions=9 was generating .p2align 4,,8 .p2align 3 which means: "align to 16 if the skip is 8 bytes or less; else align to 8". After this change, ".p2align 3" is not emitted. This behavior will be implemented differently by the next patch. The new SUBALIGN_LOG define will be used by the next patch. While we are here, avoid generating ".p2align N,,2^N-1" - it is functionally equivalent to ".p2align N". In this case, use the latter. 2016-09-27 Denys Vlasenko * config/i386/dragonfly.h: (ASM_OUTPUT_MAX_SKIP_ALIGN): Use a simpler align directive also if MAXSKIP = ALIGN-1. * config/i386/gas.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/lynx.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/netbsd-elf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/i386.h (ASM_OUTPUT_MAX_SKIP_PAD): Likewise. * config/i386/freebsd.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Remove "If N is large, do at least 8 byte alignment" code. Add SUBALIGN_LOG define. Use a simpler align directive also if MAXSKIP = ALIGN-1. * config/i386/gnu-user.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/iamcu.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/openbsdelf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/x86-64.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. Index: gcc/config/i386/dragonfly.h === --- gcc/config/i386/dragonfly.h (revision 239860) +++ gcc/config/i386/dragonfly.h (working copy) @@ -69,10 +69,12 @@ see the files COPYING3 and COPYING.RUNTIME respect #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN #undef ASM_OUTPUT_MAX_SKIP_ALIGN -#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ - if ((LOG) != 0) { \ -if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ -else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ + if ((LOG) != 0) {\ +if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ +else \ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ } #endif Index: gcc/config/i386/freebsd.h === --- gcc/config/i386/freebsd.h (revision 239860) +++ gcc/config/i386/freebsd.h (working copy) @@ -92,9 +92,9 @@ along with GCC; see the file COPYING3. If not see /* A C statement to output to the stdio stream FILE an assembler command to advance the location counter to a multiple of 1<= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else \ 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) \ - && (MAX_SKIP) >= 7) \ - fputs ("\t.p2align 3\n", (FILE)); \ - } \ } \ } while (0) #endif Index: gcc/config/i386/gas.h === --- gcc/config/i386/gas.h (revision 239860) +++ gcc/config/i386/gas.h (working copy) @@ -72,10 +72,12 @@ along with GCC; see the file COPYING3. If not see #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN # define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ - if ((LOG) != 0) {\ - if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ - else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ - } +if ((LOG) != 0) { \ + if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else \ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +} #endif /* A C statement or statements which output an assembler instruction Index: gcc/config/i386/gnu-user.h === --- gcc/config/i386/gnu-user.h (revision 239860
[PATCH 2/3] Temporary remove "at least 8 byte alignment" code from x86
This change drops forced alignment to 8 if requested alignment is higher than 8: before the patch, -falign-functions=9 was generating .p2align 4,,8 .p2align 3 which means: "align to 16 if the skip is 8 bytes or less; else align to 8". After this change, ".p2align 3" is not emitted. This behavior will be implemented differently by the next patch. The new SUBALIGN_LOG define will be used by the next patch. While we are here, avoid generating ".p2align N,,2^N-1" - it is functionally equivalent to ".p2align N". In this case, use the latter. 2016-09-27 Denys Vlasenko * config/i386/dragonfly.h: (ASM_OUTPUT_MAX_SKIP_ALIGN): Use a simpler align directive also if MAXSKIP = ALIGN-1. * config/i386/gas.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/lynx.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/netbsd-elf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/i386.h (ASM_OUTPUT_MAX_SKIP_PAD): Likewise. * config/i386/freebsd.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Remove "If N is large, do at least 8 byte alignment" code. Add SUBALIGN_LOG define. Use a simpler align directive also if MAXSKIP = ALIGN-1. * config/i386/gnu-user.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/iamcu.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/openbsdelf.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. * config/i386/x86-64.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Likewise. Index: gcc/config/i386/dragonfly.h === --- gcc/config/i386/dragonfly.h (revision 239860) +++ gcc/config/i386/dragonfly.h (working copy) @@ -69,10 +69,12 @@ see the files COPYING3 and COPYING.RUNTIME respect #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN #undef ASM_OUTPUT_MAX_SKIP_ALIGN -#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ - if ((LOG) != 0) { \ -if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ -else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ + if ((LOG) != 0) {\ +if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ +else \ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ } #endif Index: gcc/config/i386/freebsd.h === --- gcc/config/i386/freebsd.h (revision 239860) +++ gcc/config/i386/freebsd.h (working copy) @@ -92,9 +92,9 @@ along with GCC; see the file COPYING3. If not see /* A C statement to output to the stdio stream FILE an assembler command to advance the location counter to a multiple of 1<= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else \ 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) \ - && (MAX_SKIP) >= 7) \ - fputs ("\t.p2align 3\n", (FILE)); \ - } \ } \ } while (0) #endif Index: gcc/config/i386/gas.h === --- gcc/config/i386/gas.h (revision 239860) +++ gcc/config/i386/gas.h (working copy) @@ -72,10 +72,12 @@ along with GCC; see the file COPYING3. If not see #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN # define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ - if ((LOG) != 0) {\ - if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ - else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ - } +if ((LOG) != 0) { \ + if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1<<(LOG))-1) \ + fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ + else \ + fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ +} #endif /* A C statement or statements which output an assembler instruction Index: gcc/config/i386/gnu-user.h === --- gcc/config/i386/gnu-user.h (revision 239860