* [Patch AArch64] Do not increase data alignment at -Os and with -fconserve-stack.
@ 2017-05-02 10:01 Ramana Radhakrishnan
2017-06-06 13:34 ` Ramana Radhakrishnan
2017-06-08 16:48 ` James Greenhalgh
0 siblings, 2 replies; 3+ messages in thread
From: Ramana Radhakrishnan @ 2017-05-02 10:01 UTC (permalink / raw)
To: GCC Patches; +Cc: Richard Earnshaw
[-- Attachment #1: Type: text/plain, Size: 598 bytes --]
We unnecessarily align data to 8 byte alignments even when -Os is
specified. This brings the logic in the AArch64 backend more in line
with the ARM backend and helps gain some image size in a few places.
Caught by an internal report on the size of rodata sections being high
with aarch64 gcc.
* config/aarch64/aarch64.h (AARCH64_EXPAND_ALIGNMENT): New.
(DATA_ALIGNMENT): Update to use AARCH64_EXPAND_ALIGNMENT.
(LOCAL_ALIGNMENT): Update to use AARCH64_EXPAND_ALIGNMENT.
Bootstrapped and regression tested on aarch64-none-linux-gnu with no
regressions.
Ok to commit ?
cheers
Ramana
[-- Attachment #2: data-alignment-os.txt --]
[-- Type: text/plain, Size: 1498 bytes --]
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index e4fb96f..95907b2 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -98,14 +98,24 @@
&& (ALIGN) < BITS_PER_WORD) \
? BITS_PER_WORD : ALIGN)
-#define DATA_ALIGNMENT(EXP, ALIGN) \
- ((((ALIGN) < BITS_PER_WORD) \
- && (TREE_CODE (EXP) == ARRAY_TYPE \
- || TREE_CODE (EXP) == UNION_TYPE \
- || TREE_CODE (EXP) == RECORD_TYPE)) \
- ? BITS_PER_WORD : (ALIGN))
-
-#define LOCAL_ALIGNMENT(EXP, ALIGN) DATA_ALIGNMENT(EXP, ALIGN)
+/* Align definitions of arrays, unions and structures so that
+ initializations and copies can be made more efficient. This is not
+ ABI-changing, so it only affects places where we can see the
+ definition. Increasing the alignment tends to introduce padding,
+ so don't do this when optimizing for size/conserving stack space. */
+#define AARCH64_EXPAND_ALIGNMENT(COND, EXP, ALIGN) \
+ (((COND) && ((ALIGN) < BITS_PER_WORD) \
+ && (TREE_CODE (EXP) == ARRAY_TYPE \
+ || TREE_CODE (EXP) == UNION_TYPE \
+ || TREE_CODE (EXP) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
+
+/* Align global data. */
+#define DATA_ALIGNMENT(EXP, ALIGN) \
+ AARCH64_EXPAND_ALIGNMENT (!optimize_size, EXP, ALIGN)
+
+/* Similarly, make sure that objects on the stack are sensibly aligned. */
+#define LOCAL_ALIGNMENT(EXP, ALIGN) \
+ AARCH64_EXPAND_ALIGNMENT (!flag_conserve_stack, EXP, ALIGN)
#define STRUCTURE_SIZE_BOUNDARY 8
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch AArch64] Do not increase data alignment at -Os and with -fconserve-stack.
2017-05-02 10:01 [Patch AArch64] Do not increase data alignment at -Os and with -fconserve-stack Ramana Radhakrishnan
@ 2017-06-06 13:34 ` Ramana Radhakrishnan
2017-06-08 16:48 ` James Greenhalgh
1 sibling, 0 replies; 3+ messages in thread
From: Ramana Radhakrishnan @ 2017-06-06 13:34 UTC (permalink / raw)
To: Ramana Radhakrishnan; +Cc: GCC Patches, Richard Earnshaw, James Greenhalgh
Ping..
Ramana
On Tue, May 2, 2017 at 10:52 AM, Ramana Radhakrishnan
<ramana.radhakrishnan@foss.arm.com> wrote:
> We unnecessarily align data to 8 byte alignments even when -Os is specified.
> This brings the logic in the AArch64 backend more in line with the ARM
> backend and helps gain some image size in a few places. Caught by an
> internal report on the size of rodata sections being high with aarch64 gcc.
>
> * config/aarch64/aarch64.h (AARCH64_EXPAND_ALIGNMENT): New.
> (DATA_ALIGNMENT): Update to use AARCH64_EXPAND_ALIGNMENT.
> (LOCAL_ALIGNMENT): Update to use AARCH64_EXPAND_ALIGNMENT.
>
> Bootstrapped and regression tested on aarch64-none-linux-gnu with no
> regressions.
>
> Ok to commit ?
>
>
> cheers
> Ramana
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch AArch64] Do not increase data alignment at -Os and with -fconserve-stack.
2017-05-02 10:01 [Patch AArch64] Do not increase data alignment at -Os and with -fconserve-stack Ramana Radhakrishnan
2017-06-06 13:34 ` Ramana Radhakrishnan
@ 2017-06-08 16:48 ` James Greenhalgh
1 sibling, 0 replies; 3+ messages in thread
From: James Greenhalgh @ 2017-06-08 16:48 UTC (permalink / raw)
To: Ramana Radhakrishnan; +Cc: GCC Patches, Richard Earnshaw, nd
On Tue, May 02, 2017 at 10:52:13AM +0100, Ramana Radhakrishnan wrote:
> We unnecessarily align data to 8 byte alignments even when -Os is
> specified. This brings the logic in the AArch64 backend more in line
> with the ARM backend and helps gain some image size in a few places.
> Caught by an internal report on the size of rodata sections being
> high with aarch64 gcc.
>
> * config/aarch64/aarch64.h (AARCH64_EXPAND_ALIGNMENT): New.
> (DATA_ALIGNMENT): Update to use AARCH64_EXPAND_ALIGNMENT.
> (LOCAL_ALIGNMENT): Update to use AARCH64_EXPAND_ALIGNMENT.
>
> Bootstrapped and regression tested on aarch64-none-linux-gnu with no
> regressions.
>
> Ok to commit ?
OK.
Thanks,
James
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-08 16:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-02 10:01 [Patch AArch64] Do not increase data alignment at -Os and with -fconserve-stack Ramana Radhakrishnan
2017-06-06 13:34 ` Ramana Radhakrishnan
2017-06-08 16:48 ` James Greenhalgh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).