* [patch i386]: Avoid for leaf functions stack_alignment_needed
@ 2010-06-11 18:28 Kai Tietz
2010-06-11 19:18 ` H.J. Lu
0 siblings, 1 reply; 5+ messages in thread
From: Kai Tietz @ 2010-06-11 18:28 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 502 bytes --]
Hi,
this patch addresses the emit of stack-alignment for leaf functions
without register-saves, additional local stack, and no
tls-descriptor-call.
ChangeLog
2010-06-11 Kai Tietz
* config/i386/i386.c (ix86_compute_frame_layout): Avoid stack-alignment
for simple leaf-functions.
Tested for x86_64-pc-mingw32, and i686-pc-cygwin.
Ok for apply?
Regards,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
[-- Attachment #2: opt_x64_frame.diff --]
[-- Type: application/octet-stream, Size: 626 bytes --]
Index: gcc/gcc/config/i386/i386.c
===================================================================
--- gcc.orig/gcc/config/i386/i386.c 2010-06-11 18:15:35.948017200 +0200
+++ gcc/gcc/config/i386/i386.c 2010-06-11 19:18:49.973023000 +0200
@@ -8190,6 +8190,11 @@
frame->padding1 = ((offset + stack_alignment_needed - 1)
& -stack_alignment_needed) - offset;
+ if (!size && offset == UNITS_PER_WORD &&
+ current_function_is_leaf && cfun->calls_alloca == 0
+ && !ix86_current_function_calls_tls_descriptor)
+ frame->padding1 = 0;
+
offset += frame->padding1;
/* Frame pointer points here. */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch i386]: Avoid for leaf functions stack_alignment_needed
2010-06-11 18:28 [patch i386]: Avoid for leaf functions stack_alignment_needed Kai Tietz
@ 2010-06-11 19:18 ` H.J. Lu
2010-06-12 12:16 ` Kai Tietz
0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2010-06-11 19:18 UTC (permalink / raw)
To: Kai Tietz; +Cc: GCC Patches
On Fri, Jun 11, 2010 at 10:47 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hi,
>
> this patch addresses the emit of stack-alignment for leaf functions
> without register-saves, additional local stack, and no
> tls-descriptor-call.
>
> ChangeLog
>
> 2010-06-11 Kai Tietz
>
> * config/i386/i386.c (ix86_compute_frame_layout): Avoid stack-alignment
> for simple leaf-functions.
>
> Tested for x86_64-pc-mingw32, and i686-pc-cygwin.
> Ok for apply?
>
Is there a testcase?
--
H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch i386]: Avoid for leaf functions stack_alignment_needed
2010-06-11 19:18 ` H.J. Lu
@ 2010-06-12 12:16 ` Kai Tietz
2010-06-16 9:51 ` Kai Tietz
0 siblings, 1 reply; 5+ messages in thread
From: Kai Tietz @ 2010-06-12 12:16 UTC (permalink / raw)
To: H.J. Lu; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 1023 bytes --]
2010/6/11 H.J. Lu <hjl.tools@gmail.com>:
> On Fri, Jun 11, 2010 at 10:47 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>> Hi,
>>
>> this patch addresses the emit of stack-alignment for leaf functions
>> without register-saves, additional local stack, and no
>> tls-descriptor-call.
>>
>> ChangeLog
>>
>> 2010-06-11 Kai Tietz
>>
>> * config/i386/i386.c (ix86_compute_frame_layout): Avoid stack-alignment
>> for simple leaf-functions.
>>
>> Tested for x86_64-pc-mingw32, and i686-pc-cygwin.
>> Ok for apply?
>>
>
> Is there a testcase?
>
> --
> H.J.
>
I added to leaf function tests for this patch
Additional ChangeLog for testsuite
* gcc.target/x86_64/abi/callabi/leaf-1.c: New test.
* gcc.target/x86_64/abi/callabi/leaf-2.c: New test.
Tested for x86_64-pc-linux-gnu, and for x86_64-pc-mingw32. Ok for apply?
Regards,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
[-- Attachment #2: opt_x64_frame.diff --]
[-- Type: application/octet-stream, Size: 1833 bytes --]
Index: gcc/gcc/config/i386/i386.c
===================================================================
--- gcc.orig/gcc/config/i386/i386.c 2010-06-12 11:01:30.809062300 +0200
+++ gcc/gcc/config/i386/i386.c 2010-06-12 12:06:17.727381300 +0200
@@ -8190,6 +8190,11 @@
frame->padding1 = ((offset + stack_alignment_needed - 1)
& -stack_alignment_needed) - offset;
+ if (!size && offset == ((frame->nregs + 1) * UNITS_PER_WORD)
+ && current_function_is_leaf && cfun->calls_alloca == 0
+ && !ix86_current_function_calls_tls_descriptor)
+ frame->padding1 = 0;
+
offset += frame->padding1;
/* Frame pointer points here. */
Index: gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-1.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-1.c 2010-06-12 11:42:45.859627000 +0200
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mabi=sysv" } */
+
+__attribute__ ((ms_abi))
+int foo (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-assembler-not "%rsp" } } */
+
Index: gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-2.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/gcc/testsuite/gcc.target/x86_64/abi/callabi/leaf-2.c 2010-06-12 12:01:27.105758700 +0200
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mabi=sysv" } */
+
+extern int glb1, gbl2, gbl3;
+
+__attribute__ ((ms_abi))
+int foo (void)
+{
+ int r = 1;
+ int i, j, k;
+ for (i = 0; i < glb1; i++)
+ {
+ r *= (i + 1);
+ for (j = gbl2; j > 0; --j)
+ {
+ for (k = 0; k < gbl3; k++)
+ r += (i + k * j);
+ }
+ }
+
+ return r;
+}
+
+/* { dg-final { scan-assembler-not "%rsp" } } */
+
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch i386]: Avoid for leaf functions stack_alignment_needed
2010-06-12 12:16 ` Kai Tietz
@ 2010-06-16 9:51 ` Kai Tietz
2010-06-21 9:56 ` Kai Tietz
0 siblings, 1 reply; 5+ messages in thread
From: Kai Tietz @ 2010-06-16 9:51 UTC (permalink / raw)
To: Uros Bizjak; +Cc: GCC Patches
PING
2010/6/12 Kai Tietz <ktietz70@googlemail.com>:
> 2010/6/11 H.J. Lu <hjl.tools@gmail.com>:
>> On Fri, Jun 11, 2010 at 10:47 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>> Hi,
>>>
>>> this patch addresses the emit of stack-alignment for leaf functions
>>> without register-saves, additional local stack, and no
>>> tls-descriptor-call.
>>>
>>> ChangeLog
>>>
>>> 2010-06-11 Kai Tietz
>>>
>>> * config/i386/i386.c (ix86_compute_frame_layout): Avoid stack-alignment
>>> for simple leaf-functions.
>>>
>>> Tested for x86_64-pc-mingw32, and i686-pc-cygwin.
>>> Ok for apply?
>>>
>>
>> Is there a testcase?
>>
>> --
>> H.J.
>>
>
> I added to leaf function tests for this patch
>
> Additional ChangeLog for testsuite
>
> * gcc.target/x86_64/abi/callabi/leaf-1.c: New test.
> * gcc.target/x86_64/abi/callabi/leaf-2.c: New test.
>
> Tested for x86_64-pc-linux-gnu, and for x86_64-pc-mingw32. Ok for apply?
>
> Regards,
> Kai
>
> --
> | (\_/) This is Bunny. Copy and paste
> | (='.'=) Bunny into your signature to help
> | (")_(") him gain world domination
>
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch i386]: Avoid for leaf functions stack_alignment_needed
2010-06-16 9:51 ` Kai Tietz
@ 2010-06-21 9:56 ` Kai Tietz
0 siblings, 0 replies; 5+ messages in thread
From: Kai Tietz @ 2010-06-21 9:56 UTC (permalink / raw)
To: Uros Bizjak; +Cc: GCC Patches, Jan Hubicka
2010/6/16 Kai Tietz <ktietz70@googlemail.com>:
> PING
>
> 2010/6/12 Kai Tietz <ktietz70@googlemail.com>:
>> 2010/6/11 H.J. Lu <hjl.tools@gmail.com>:
>>> On Fri, Jun 11, 2010 at 10:47 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>>> Hi,
>>>>
>>>> this patch addresses the emit of stack-alignment for leaf functions
>>>> without register-saves, additional local stack, and no
>>>> tls-descriptor-call.
>>>>
>>>> ChangeLog
>>>>
>>>> 2010-06-11 Kai Tietz
>>>>
>>>> * config/i386/i386.c (ix86_compute_frame_layout): Avoid stack-alignment
>>>> for simple leaf-functions.
>>>>
>>>> Tested for x86_64-pc-mingw32, and i686-pc-cygwin.
>>>> Ok for apply?
>>>>
>>>
>>> Is there a testcase?
>>>
>>> --
>>> H.J.
>>>
>>
>> I added to leaf function tests for this patch
>>
>> Additional ChangeLog for testsuite
>>
>> * gcc.target/x86_64/abi/callabi/leaf-1.c: New test.
>> * gcc.target/x86_64/abi/callabi/leaf-2.c: New test.
>>
>> Tested for x86_64-pc-linux-gnu, and for x86_64-pc-mingw32. Ok for apply?
>>
>> Regards,
>> Kai
>>
>> --
>> | (\_/) This is Bunny. Copy and paste
>> | (='.'=) Bunny into your signature to help
>> | (")_(") him gain world domination
>>
>
>
>
> --
> | (\_/) This is Bunny. Copy and paste
> | (='.'=) Bunny into your signature to help
> | (")_(") him gain world domination
>
Committed adjusted patch at revision 161064 (and testsuite part at
161063). Patch approved by Jan on IRC.
Thanks,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-21 7:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-11 18:28 [patch i386]: Avoid for leaf functions stack_alignment_needed Kai Tietz
2010-06-11 19:18 ` H.J. Lu
2010-06-12 12:16 ` Kai Tietz
2010-06-16 9:51 ` Kai Tietz
2010-06-21 9:56 ` Kai Tietz
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).