[Bug tree-optimization/39839] [4.3/4.4/4.5/4.6 regression] loop invariant motion causes stack spill

sandra at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 22 16:27:00 GMT 2010



------- Comment #10 from sandra at codesourcery dot com  2010-06-22 16:26 -------
It looks like this bug has been fixed by my proposed patch for PR42505:

http://gcc.gnu.org/ml/gcc-patches/2010-06/msg01920.html

Applying that patch to r160755 gives:

00000000 <test>:
   0:   b570            push    {r4, r5, r6, lr}
   2:   4d0c            ldr     r5, [pc, #48]   ; (34 <test+0x34>)
   4:   1c04            adds    r4, r0, #0
   6:   6806            ldr     r6, [r0, #0]
   8:   447d            add     r5, pc
   a:   e00f            b.n     2c <test+0x2c>
   c:   6861            ldr     r1, [r4, #4]
   e:   1c2b            adds    r3, r5, #0
  10:   780a            ldrb    r2, [r1, #0]
  12:   2a00            cmp     r2, #0
  14:   d101            bne.n   1a <test+0x1a>
  16:   4b08            ldr     r3, [pc, #32]   ; (38 <test+0x38>)
  18:   447b            add     r3, pc
  1a:   4808            ldr     r0, [pc, #32]   ; (3c <test+0x3c>)
  1c:   1989            adds    r1, r1, r6
  1e:   4478            add     r0, pc
  20:   1c32            adds    r2, r6, #0
  22:   f7ff fffe       bl      0 <func>
  26:   6823            ldr     r3, [r4, #0]
  28:   3b01            subs    r3, #1
  2a:   6023            str     r3, [r4, #0]
  2c:   6823            ldr     r3, [r4, #0]
  2e:   2b00            cmp     r3, #0
  30:   daec            bge.n   c <test+0xc>
  32:   bd70            pop     {r4, r5, r6, pc}
  34:   00000028        .word   0x00000028
  38:   0000001c        .word   0x0000001c
  3c:   0000001a        .word   0x0000001a

So, back down to 64 bytes of code, and no spills to stack.

Assuming the PR42505 patch is approved, probably the only thing required to
close this issue is checking in the additional test case.


-- 

sandra at codesourcery dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sandra at codesourcery dot
                   |                            |com


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



More information about the Gcc-bugs mailing list