public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/43513]  New: The stack pointer is adjusted twice
@ 2010-03-25  9:19 carrot at google dot com
  2010-03-25  9:20 ` [Bug target/43513] " carrot at google dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: carrot at google dot com @ 2010-03-25  9:19 UTC (permalink / raw)
  To: gcc-bugs

Compile the attached code with options -march=armv7-a -mthumb -Os -fpic, gcc
generates:

foo3:
        push    {r4, r5, r6, r7, lr}
        sub     sp, sp, #12      // A
        ldr     r3, .L4
        add     r7, sp, #0       // B
        sub     sp, sp, #48      // C
        mov     r0, sp
         ...

Instruction A is used to allocate space for spilled variables. Instruction B
setups a frame pointer. Instruction C allocate space for local variables.
Instruction A and C can be merged into one, so ABC can be rewritten as:

        sub     sp, sp, 60
        add     r7, sp, r8

Instruction C is emitted at the expand phase. But instructions AB is emitted
from function arm_expand_prologue in pro_and_epilogue pass. So one possible
solution is stop emitting code to allocate space for local variables. Instead
record the local variables' space size and allocate the space with spill space
together in pro_and_epilogue pass.


-- 
           Summary: The stack pointer is adjusted twice
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: carrot at google dot com
 GCC build triplet: i686-linux
  GCC host triplet: i686-linux
GCC target triplet: arm-eabi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/43513] The stack pointer is adjusted twice
  2010-03-25  9:19 [Bug target/43513] New: The stack pointer is adjusted twice carrot at google dot com
@ 2010-03-25  9:20 ` carrot at google dot com
  2010-03-25  9:53 ` steven at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: carrot at google dot com @ 2010-03-25  9:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from carrot at google dot com  2010-03-25 09:20 -------
Created an attachment (id=20195)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20195&action=view)
test case


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/43513] The stack pointer is adjusted twice
  2010-03-25  9:19 [Bug target/43513] New: The stack pointer is adjusted twice carrot at google dot com
  2010-03-25  9:20 ` [Bug target/43513] " carrot at google dot com
@ 2010-03-25  9:53 ` steven at gcc dot gnu dot org
  2010-03-26  6:42 ` carrot at google dot com
  2010-03-26  9:05 ` [Bug middle-end/43513] " rearnsha at gcc dot gnu dot org
  3 siblings, 0 replies; 12+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-03-25  9:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from steven at gcc dot gnu dot org  2010-03-25 09:53 -------
Any reason why combine-stack-adj.c doesn't perform this optimization for you?


-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-03-25 09:53:22
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/43513] The stack pointer is adjusted twice
  2010-03-25  9:19 [Bug target/43513] New: The stack pointer is adjusted twice carrot at google dot com
  2010-03-25  9:20 ` [Bug target/43513] " carrot at google dot com
  2010-03-25  9:53 ` steven at gcc dot gnu dot org
@ 2010-03-26  6:42 ` carrot at google dot com
  2010-03-26  9:05 ` [Bug middle-end/43513] " rearnsha at gcc dot gnu dot org
  3 siblings, 0 replies; 12+ messages in thread
From: carrot at google dot com @ 2010-03-26  6:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from carrot at google dot com  2010-03-26 06:42 -------
There are 2 problems with csa for arm:

1. In function rest_of_handle_stack_adjustments:

  if (!ACCUMULATE_OUTGOING_ARGS)
    {
      ...
    }

   ACCUMULATE_OUTGOING_ARGS is defined to 1 in arm.h, so this pass is not
applied to arm back end.

2. Even if I change the condition to enable it, the stack adjustments are still
not combined. 

   Following are related insns:

        ...

(insn/f 117 116 118 2 src/t9.c:5 (set (reg/f:SI 13 sp)
        (plus:SI (reg/f:SI 13 sp)
            (const_int -12 [0xfffffffffffffff4]))) -1 (nil))

(insn 118 117 119 2 src/t9.c:5 (set (mem:BLK (scratch) [0 A8])
        (unspec:BLK [
                (reg/f:SI 13 sp)
                (reg/f:SI 7 r7)
            ] 5)) -1 (nil))

(insn/f 119 118 120 2 src/t9.c:5 (set (reg/f:SI 7 r7)
        (plus:SI (reg/f:SI 13 sp)
            (const_int 0 [0x0]))) -1 (nil))

       ...

(insn 55 50 57 2 src/t9.c:7 (set (reg/f:SI 13 sp)
        (plus:SI (reg/f:SI 13 sp)
            (const_int -48 [0xffffffffffffffd0]))) 4 {*arm_addsi3} (nil))

       ...

    Among them insn 118 trigger the following code in function
combine_stack_adjustments_for_block, and prevent the combine of stack
adjustment codes. It is emitted along with insn 117.

      /* Otherwise, we were not able to process the instruction.
         Do not continue collecting data across such a one.  */
      if (last_sp_set
          && (CALL_P (insn)
              || reg_mentioned_p (stack_pointer_rtx, PATTERN (insn))))
        {
           /* Clear the collected stack references. */
            ...
        } 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/43513] The stack pointer is adjusted twice
  2010-03-25  9:19 [Bug target/43513] New: The stack pointer is adjusted twice carrot at google dot com
                   ` (2 preceding siblings ...)
  2010-03-26  6:42 ` carrot at google dot com
@ 2010-03-26  9:05 ` rearnsha at gcc dot gnu dot org
  3 siblings, 0 replies; 12+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2010-03-26  9:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rearnsha at gcc dot gnu dot org  2010-03-26 09:05 -------
This is a case where we have a 'variable length array' declaration but where
the variable is really const and well-known at compile time.  However, we still
end up with it being 'variably sized' at rtl expand time.

I think it would be much better if the generic optimizers could spot this case
and remove it entirely, turning it into a natural array declartion.  Then we
could eliminate even more from this function (for example, it doesn't really
need a frame pointer).

So changing to 'middle-end'.


-- 

rearnsha at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rearnsha at gcc dot gnu dot
                   |                            |org
           Severity|normal                      |enhancement
          Component|target                      |middle-end


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/43513] The stack pointer is adjusted twice
       [not found] <bug-43513-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2011-08-31  8:27 ` vries at gcc dot gnu.org
@ 2011-08-31  9:43 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2011-08-31  9:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513

vries at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vries at gcc dot gnu.org
         Resolution|DUPLICATE                   |FIXED
         AssignedTo|unassigned at gcc dot       |vries at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #11 from vries at gcc dot gnu.org 2011-08-31 08:56:42 UTC ---
Patch and test-case checked in, marking fixed.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/43513] The stack pointer is adjusted twice
       [not found] <bug-43513-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2011-08-31  7:07 ` vries at gcc dot gnu.org
@ 2011-08-31  8:27 ` vries at gcc dot gnu.org
  2011-08-31  9:43 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2011-08-31  8:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513

--- Comment #10 from vries at gcc dot gnu.org 2011-08-31 07:06:04 UTC ---
Author: vries
Date: Wed Aug 31 07:05:59 2011
New Revision: 178354

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178354
Log:
2011-08-31  Tom de Vries  <tom@codesourcery.com>

    PR middle-end/43513
    * gcc.dg/pr43513.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr43513.c
Modified:
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/43513] The stack pointer is adjusted twice
       [not found] <bug-43513-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2011-07-31 10:05 ` vries at gcc dot gnu.org
@ 2011-08-31  7:07 ` vries at gcc dot gnu.org
  2011-08-31  8:27 ` vries at gcc dot gnu.org
  2011-08-31  9:43 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2011-08-31  7:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513

--- Comment #9 from vries at gcc dot gnu.org 2011-08-31 07:04:31 UTC ---
Author: vries
Date: Wed Aug 31 07:04:25 2011
New Revision: 178353

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178353
Log:
2011-08-31  Tom de Vries  <tom@codesourcery.com>

    PR middle-end/43513
    * Makefile.in (tree-ssa-ccp.o): Add $(PARAMS_H) to rule.
    * tree-ssa-ccp.c (params.h): Include.
    (fold_builtin_alloca_for_var): New function.
    (ccp_fold_stmt): Use fold_builtin_alloca_for_var.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/tree-ssa-ccp.c


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/43513] The stack pointer is adjusted twice
       [not found] <bug-43513-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2011-07-31 10:03 ` vries at gcc dot gnu.org
@ 2011-07-31 10:05 ` vries at gcc dot gnu.org
  2011-08-31  7:07 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2011-07-31 10:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513

--- Comment #8 from vries at gcc dot gnu.org 2011-07-31 10:05:11 UTC ---
Author: vries
Date: Sun Jul 31 10:05:07 2011
New Revision: 176969

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176969
Log:
2011-07-31  Tom de Vries  <tom@codesourcery.com>

    PR middle-end/43513
    * tree-ssa-loop-ivopts.c (may_be_unaligned_p): Use max of
    get_object_alignment and TYPE_ALIGN.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-loop-ivopts.c


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/43513] The stack pointer is adjusted twice
       [not found] <bug-43513-4@http.gcc.gnu.org/bugzilla/>
  2011-07-27 10:57 ` rguenth at gcc dot gnu.org
  2011-07-30 12:39 ` vries at gcc dot gnu.org
@ 2011-07-31 10:03 ` vries at gcc dot gnu.org
  2011-07-31 10:05 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2011-07-31 10:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513

--- Comment #7 from vries at gcc dot gnu.org 2011-07-31 10:02:15 UTC ---
Author: vries
Date: Sun Jul 31 10:02:12 2011
New Revision: 176968

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176968
Log:
2011-07-31  Tom de Vries  <tom@codesourcery.com>

    PR middle-end/43513
    * testsuite/libmudflap.c/fail31-frag.c: Adapt testcase to prevent
    folding of alloca.

Modified:
    trunk/libmudflap/ChangeLog
    trunk/libmudflap/testsuite/libmudflap.c/fail31-frag.c


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/43513] The stack pointer is adjusted twice
       [not found] <bug-43513-4@http.gcc.gnu.org/bugzilla/>
  2011-07-27 10:57 ` rguenth at gcc dot gnu.org
@ 2011-07-30 12:39 ` vries at gcc dot gnu.org
  2011-07-31 10:03 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2011-07-30 12:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513

--- Comment #6 from vries at gcc dot gnu.org 2011-07-30 12:37:50 UTC ---
Author: vries
Date: Sat Jul 30 12:37:47 2011
New Revision: 176959

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176959
Log:
2011-07-30  Tom de Vries  <tom@codesourcery.com>

    PR middle-end/43513
    * tree-ssa-dce.c (ref_may_be_aliased): Add assert.
    (propagate_necessity): Handle WITH_SIZE_EXPR call arg.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-dce.c


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/43513] The stack pointer is adjusted twice
       [not found] <bug-43513-4@http.gcc.gnu.org/bugzilla/>
@ 2011-07-27 10:57 ` rguenth at gcc dot gnu.org
  2011-07-30 12:39 ` vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-07-27 10:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-27 10:56:13 UTC ---
dup.

*** This bug has been marked as a duplicate of bug 26388 ***


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-08-31  8:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-25  9:19 [Bug target/43513] New: The stack pointer is adjusted twice carrot at google dot com
2010-03-25  9:20 ` [Bug target/43513] " carrot at google dot com
2010-03-25  9:53 ` steven at gcc dot gnu dot org
2010-03-26  6:42 ` carrot at google dot com
2010-03-26  9:05 ` [Bug middle-end/43513] " rearnsha at gcc dot gnu dot org
     [not found] <bug-43513-4@http.gcc.gnu.org/bugzilla/>
2011-07-27 10:57 ` rguenth at gcc dot gnu.org
2011-07-30 12:39 ` vries at gcc dot gnu.org
2011-07-31 10:03 ` vries at gcc dot gnu.org
2011-07-31 10:05 ` vries at gcc dot gnu.org
2011-08-31  7:07 ` vries at gcc dot gnu.org
2011-08-31  8:27 ` vries at gcc dot gnu.org
2011-08-31  9:43 ` vries at gcc dot gnu.org

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).