public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/53735] New: thumb1 spill failure with -Os
@ 2012-06-20 18:56 aldot at gcc dot gnu.org
  2012-06-20 18:58 ` [Bug target/53735] " aldot at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: aldot at gcc dot gnu.org @ 2012-06-20 18:56 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53735
           Summary: thumb1 spill failure with -Os
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Keywords: assemble-failure, ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: aldot@gcc.gnu.org
                CC: ramana@gcc.gnu.org, rearnsha@gcc.gnu.org
            Target: arm-eabi


Created attachment 27667
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27667
original source

fork() fails to assemble with -mthumb -Os, works with -O2 instead of -Os.

arm-oe-linux-uclibceabi-gcc -S fork.i -o fork.s -mthumb -Os ;# -g
-march=armv5te -mthumb-interwork -mtune=arm926ej-s -msoft-float -mlittle-endian
-feliminate-unused-debug-types -fno-tree-loop-optimize -fno-tree-dominator-opts 
fork.i: In function 'fork':
fork.i:8762:1: error: unable to find a register to spill in class 'LO_REGS'
fork.i:8762:1: error: this is the insn:
(insn 99 97 100 17 (set (reg/v:SI 4 r4 [ _v1 ])
        (plus:SI (reg/f:SI 147 [ D.8653 ])
            (const_int -1064 [0xfffffffffffffbd8])))
fork.i:8727 5 {*thumb1_addsi3}
     (nil))
fork.i:8762: confused by earlier errors, bailing out


Attached fork.i is the original, fork-reduced.i is a slightly reduced variant.
Above my original flags commented out for reference.


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

* [Bug target/53735] thumb1 spill failure with -Os
  2012-06-20 18:56 [Bug target/53735] New: thumb1 spill failure with -Os aldot at gcc dot gnu.org
@ 2012-06-20 18:58 ` aldot at gcc dot gnu.org
  2012-07-17  9:34 ` ramana at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: aldot at gcc dot gnu.org @ 2012-06-20 18:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Bernhard Reutner-Fischer <aldot at gcc dot gnu.org> 2012-06-20 18:58:06 UTC ---
Created attachment 27668
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27668
reduced source


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

* [Bug target/53735] thumb1 spill failure with -Os
  2012-06-20 18:56 [Bug target/53735] New: thumb1 spill failure with -Os aldot at gcc dot gnu.org
  2012-06-20 18:58 ` [Bug target/53735] " aldot at gcc dot gnu.org
@ 2012-07-17  9:34 ` ramana at gcc dot gnu.org
  2012-07-24  9:04 ` zhuolin.liu at arm dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ramana at gcc dot gnu.org @ 2012-07-17  9:34 UTC (permalink / raw)
  To: gcc-bugs

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

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|assemble-failure            |
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-07-17
     Ever Confirmed|0                           |1
      Known to fail|                            |4.8.0

--- Comment #2 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2012-07-17 09:34:05 UTC ---
It's really not an assemble failure. The problem is in the compiler and it
looks prima-facie like ICE on valid code.


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

* [Bug target/53735] thumb1 spill failure with -Os
  2012-06-20 18:56 [Bug target/53735] New: thumb1 spill failure with -Os aldot at gcc dot gnu.org
  2012-06-20 18:58 ` [Bug target/53735] " aldot at gcc dot gnu.org
  2012-07-17  9:34 ` ramana at gcc dot gnu.org
@ 2012-07-24  9:04 ` zhuolin.liu at arm dot com
  2012-07-26  7:51 ` zhenqiang.chen at linaro dot org
  2013-08-05 21:34 ` rearnsha at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: zhuolin.liu at arm dot com @ 2012-07-24  9:04 UTC (permalink / raw)
  To: gcc-bugs

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

zhuolin liu <zhuolin.liu at arm dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zhuolin.liu at arm dot com

--- Comment #3 from zhuolin liu <zhuolin.liu at arm dot com> 2012-07-24 09:04:15 UTC ---
simple code

fork() fails to assemble with -mthumb -Os, works with -O2 instead of -Os.

register int aa5 __asm__ ("r4") ;
register int aa6 __asm__ ("r5") ;
struct pthread
{
  int tid;
  int pid;
  int ss[128];
};
int add_lock;
int fork (void)
{
   int * meself = __builtin_thread_pointer () - 1;
    if (add_lock !=(int)meself)
      {
        __lll_lock_wait_private (0);
      }
      register int __a1 __asm__ ("a1")=1;
      register int _v3 __asm__ ("v3") = 1;
      int _v1tmp = (int) (&((struct pthread *)__builtin_thread_pointer () -
1)->tid);
       register int __a2 __asm__ ("a2") =1;
       register int __a3 __asm__ ("a3") =1;
       register int __a4 __asm__ ("a4") =1;
       register int _v1 __asm__ ("v1") = _v1tmp;
       __asm__ __volatile__ ( "\n" : :"r" (_v3) , "r" (__a1), "r" (__a2), "r"
(__a3), "r" (__a4), "r" (_v1) :);
}


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

* [Bug target/53735] thumb1 spill failure with -Os
  2012-06-20 18:56 [Bug target/53735] New: thumb1 spill failure with -Os aldot at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-07-24  9:04 ` zhuolin.liu at arm dot com
@ 2012-07-26  7:51 ` zhenqiang.chen at linaro dot org
  2013-08-05 21:34 ` rearnsha at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: zhenqiang.chen at linaro dot org @ 2012-07-26  7:51 UTC (permalink / raw)
  To: gcc-bugs

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

zhenqiang.chen at linaro dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zhenqiang.chen at linaro
                   |                            |dot org

--- Comment #4 from zhenqiang.chen at linaro dot org 2012-07-26 07:50:25 UTC ---
Root cause: r8-r11 is not available for THUMB1 with -Os.

In function arm_conditional_register_usage (arm.c), you can find the code

  if (TARGET_THUMB1 && optimize_size)
    {
      /* When optimizing for size on Thumb-1, it's better not
        to use the HI regs, because of the overhead of
        stacking them.  */
      for (regno = FIRST_HI_REGNUM;
       regno <= LAST_HI_REGNUM; ++regno)
    fixed_regs[regno] = call_used_regs[regno] = 1;
    }

If removing the code, the result is OK (r8 is used).


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

* [Bug target/53735] thumb1 spill failure with -Os
  2012-06-20 18:56 [Bug target/53735] New: thumb1 spill failure with -Os aldot at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-07-26  7:51 ` zhenqiang.chen at linaro dot org
@ 2013-08-05 21:34 ` rearnsha at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2013-08-05 21:34 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:

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

--- Comment #5 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Realistically, we're never going to be able to fix this.  You've tied the
compilers hands behind it's back and it's then unable to keep its balance when
you give it a push.

In Thumb1 code, when optimizing for space, you've got just r0-r6 available in
general (r7 is used for the frame pointer).  Your source code tries to use all
7 of them (a1[r0]-a4[r3], v1[r4], r5 and v3[r6]).  That just leaves r7 (the
frame pointer) for the compiler to use for everything, so it's no surprise that
things then fall apart.


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

end of thread, other threads:[~2013-08-05 21:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-20 18:56 [Bug target/53735] New: thumb1 spill failure with -Os aldot at gcc dot gnu.org
2012-06-20 18:58 ` [Bug target/53735] " aldot at gcc dot gnu.org
2012-07-17  9:34 ` ramana at gcc dot gnu.org
2012-07-24  9:04 ` zhuolin.liu at arm dot com
2012-07-26  7:51 ` zhenqiang.chen at linaro dot org
2013-08-05 21:34 ` rearnsha 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).