public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/34312]  New: spill failure with -O2 -fPIC -march=pentium-m on i386
@ 2007-12-01 23:17 christophe at saout dot de
  2007-12-01 23:19 ` [Bug target/34312] " christophe at saout dot de
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: christophe at saout dot de @ 2007-12-01 23:17 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1308 bytes --]

I get this with the gcc 4.3 snapshot from 20071130 when compiling thunderbird:

leto:/home/chtephan > LANG=C g++ -o breaks.o -c breaks.i -O2 -march=pentium-m
-fPIC
nsUnicodeToJamoTTF.cpp: In function ‘const JamoNormMap*
JamoClusterSearch(JamoNormMap, const JamoNormMap*, PRInt16)’:
nsUnicodeToJamoTTF.cpp:811: error: unable to find a register to spill in class
‘Q_REGS’
nsUnicodeToJamoTTF.cpp:811: error: this is the insn:
(insn:HI 209 207 211 2 nsUnicodeToJamoTTF.cpp:783 (parallel [
            (set (subreg:SI (reg:QI 134) 0)
                (lshiftrt:SI (reg:SI 4 si [136])
                    (const_int 8 [0x8])))
            (clobber (reg:CC 17 flags))
        ]) 358 {*lshrsi3_1} (expr_list:REG_DEAD (reg:SI 4 si [136])
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))


-- 
           Summary: spill failure with -O2 -fPIC -march=pentium-m on i386
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christophe at saout dot de
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug target/34312] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
@ 2007-12-01 23:19 ` christophe at saout dot de
  2007-12-03 11:25 ` ubizjak at gmail dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: christophe at saout dot de @ 2007-12-01 23:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from christophe at saout dot de  2007-12-01 23:19 -------
Created an attachment (id=14679)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14679&action=view)
preprocessed source file

gunzip breaks.i.gz; g++ -o breaks.o -c breaks.i -O2 -march=pentium-m -fPIC


-- 


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


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

* [Bug target/34312] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
  2007-12-01 23:19 ` [Bug target/34312] " christophe at saout dot de
@ 2007-12-03 11:25 ` ubizjak at gmail dot com
  2007-12-03 11:28 ` [Bug target/34312] [4.3 regression] " ubizjak at gmail dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ubizjak at gmail dot com @ 2007-12-03 11:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ubizjak at gmail dot com  2007-12-03 11:25 -------
Created an attachment (id=14688)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14688&action=view)
reduced c testcase


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #14679|0                           |1
        is obsolete|                            |


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


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

* [Bug target/34312] [4.3 regression] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
  2007-12-01 23:19 ` [Bug target/34312] " christophe at saout dot de
  2007-12-03 11:25 ` ubizjak at gmail dot com
@ 2007-12-03 11:28 ` ubizjak at gmail dot com
  2007-12-03 13:45 ` [Bug rtl-optimization/34312] " ubizjak at gmail dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ubizjak at gmail dot com @ 2007-12-03 11:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ubizjak at gmail dot com  2007-12-03 11:28 -------
Confirmed. Register allocator issue.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |ra
      Known to work|                            |4.2.3 4.1.3 4.0.4
   Last reconfirmed|0000-00-00 00:00:00         |2007-12-03 11:28:04
               date|                            |
            Summary|spill failure with -O2 -fPIC|[4.3 regression] spill
                   |-march=pentium-m on i386    |failure with -O2 -fPIC -
                   |                            |march=pentium-m on i386


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


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

* [Bug rtl-optimization/34312] [4.3 regression] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
                   ` (2 preceding siblings ...)
  2007-12-03 11:28 ` [Bug target/34312] [4.3 regression] " ubizjak at gmail dot com
@ 2007-12-03 13:45 ` ubizjak at gmail dot com
  2007-12-03 15:16 ` bonzini at gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ubizjak at gmail dot com @ 2007-12-03 13:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ubizjak at gmail dot com  2007-12-03 13:45 -------
This all comes down to PR 19398. Since JamoClusterSearch() is defined as
static, gcc switches to register passing convention, and this uses %eax, %edx
and %ecx. %ebx is used as a PIC register, so we are out of QImode registers.

The pattern is defined as:

(define_insn "*lshrsi3_1"
  [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
        (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
                     (match_operand:QI 2 "nonmemory_operand" "I,c")))
   (clobber (reg:CC FLAGS_REG))]

so reload is in fact free to use "m" alternative. Unfortunatelly, reload rather
dies than touches memory.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |19398
          Component|target                      |rtl-optimization


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


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

* [Bug rtl-optimization/34312] [4.3 regression] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
                   ` (3 preceding siblings ...)
  2007-12-03 13:45 ` [Bug rtl-optimization/34312] " ubizjak at gmail dot com
@ 2007-12-03 15:16 ` bonzini at gnu dot org
  2007-12-03 16:32 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: bonzini at gnu dot org @ 2007-12-03 15:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from bonzini at gnu dot org  2007-12-03 15:15 -------
As a start, let's limit register passing convention to regparm=2.  The risk of
running out QImode registers is quite real, as is the risk of getting extremely
bad code...


-- 

bonzini at gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bonzini at gnu dot org


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


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

* [Bug rtl-optimization/34312] [4.3 regression] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
                   ` (4 preceding siblings ...)
  2007-12-03 15:16 ` bonzini at gnu dot org
@ 2007-12-03 16:32 ` rguenth at gcc dot gnu dot org
  2007-12-03 17:52 ` rask at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-12-03 16:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2007-12-03 16:32 -------
Instead, -fPIC should unconditionally decrease the available regparm by 1.


-- 


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


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

* [Bug rtl-optimization/34312] [4.3 regression] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
                   ` (5 preceding siblings ...)
  2007-12-03 16:32 ` rguenth at gcc dot gnu dot org
@ 2007-12-03 17:52 ` rask at gcc dot gnu dot org
  2007-12-03 20:48 ` ebotcazou at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rask at gcc dot gnu dot org @ 2007-12-03 17:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rask at gcc dot gnu dot org  2007-12-03 17:52 -------
Note that reload asks for Q_REGS when the constraints allow GENERAL_REGS, so
the  root cause is just reload being stupid. I bet it is this optimization from
find_reloads() that causes it:

          if (! win && ! did_match
              && this_alternative[i] != (int) NO_REGS
              && GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD
              && reg_class_size [(int) preferred_class[i]] > 0
              && ! SMALL_REGISTER_CLASS_P (preferred_class[i]))
            {
              if (! reg_class_subset_p (this_alternative[i],
                                        preferred_class[i]))
                {
                  /* Since we don't have a way of forming the intersection,
                     we just do something special if the preferred class
                     is a subset of the class we have; that's the most
                     common case anyway.  */
                  if (reg_class_subset_p (preferred_class[i],
                                          this_alternative[i]))
                    this_alternative[i] = (int) preferred_class[i];
                  else
                    reject += (2 + 2 * pref_or_nothing[i]);
                }
            }

Additionally, i386.h CLASS_LIKELY_SPILLED_P should probably take -mregparm and
-fPIC etc. into account in deciding if Q_REGS is likely spilled or not.


-- 


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


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

* [Bug rtl-optimization/34312] [4.3 regression] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
                   ` (6 preceding siblings ...)
  2007-12-03 17:52 ` rask at gcc dot gnu dot org
@ 2007-12-03 20:48 ` ebotcazou at gcc dot gnu dot org
  2007-12-05 13:55 ` ubizjak at gmail dot com
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-12-03 20:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from ebotcazou at gcc dot gnu dot org  2007-12-03 20:48 -------
> Instead, -fPIC should unconditionally decrease the available regparm by 1.

Yes, this seems to be the best solution in the short term.


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu dot
                   |                            |org


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


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

* [Bug rtl-optimization/34312] [4.3 regression] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
                   ` (7 preceding siblings ...)
  2007-12-03 20:48 ` ebotcazou at gcc dot gnu dot org
@ 2007-12-05 13:55 ` ubizjak at gmail dot com
  2007-12-05 16:01 ` uros at gcc dot gnu dot org
  2007-12-05 16:03 ` ubizjak at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: ubizjak at gmail dot com @ 2007-12-05 13:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from ubizjak at gmail dot com  2007-12-05 13:54 -------
(In reply to comment #8)
> > Instead, -fPIC should unconditionally decrease the available regparm by 1.
> Yes, this seems to be the best solution in the short term.

I'm testing following patch:

Index: i386.c
===================================================================
--- i386.c      (revision 130622)
+++ i386.c      (working copy)
@@ -3200,7 +3200,7 @@ ix86_function_regparm (const_tree type, 
          /* Make sure no regparm register is taken by a
             global register variable.  */
          for (local_regparm = 0; local_regparm < 3; local_regparm++)
-           if (global_regs[local_regparm])
+           if (global_regs[local_regparm] || fixed_regs[local_regparm])
              break;

          /* We can't use regparm(3) for nested functions as these use
@@ -3226,7 +3226,7 @@ ix86_function_regparm (const_tree type, 
             so the more global reg vars there are, the smaller regparm
             optimization use, unless requested by the user explicitly.  */
          for (regno = 0; regno < 6; regno++)
-           if (global_regs[regno])
+           if (global_regs[regno] || fixed_regs[regno])
              globals++;
          local_regparm
            = globals < local_regparm ? local_regparm - globals : 0;

The rationale is that fixed reg, as well as global reg should decrease the
number of registers available for argument passing. When %ebx is used as -fpic
reg for 32bit targets, this does exactly what Comment #6 suggests.

This patch of course doesn't lower the importance of the fix for PR 19398. ;)


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |ubizjak at gmail dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-12-03 11:28:04         |2007-12-05 13:54:47
               date|                            |


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


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

* [Bug rtl-optimization/34312] [4.3 regression] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
                   ` (8 preceding siblings ...)
  2007-12-05 13:55 ` ubizjak at gmail dot com
@ 2007-12-05 16:01 ` uros at gcc dot gnu dot org
  2007-12-05 16:03 ` ubizjak at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: uros at gcc dot gnu dot org @ 2007-12-05 16:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from uros at gcc dot gnu dot org  2007-12-05 16:01 -------
Subject: Bug 34312

Author: uros
Date: Wed Dec  5 16:01:22 2007
New Revision: 130625

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130625
Log:
        PR target/34312
        * config/i386/i386.c (ix86_function_regparm): Also check for fixed
        registers when checking that regparm registers are available.
        Lower regparm value due to fixed registers usage in addition to
        global regs usage.

testsuite/ChangeLog:

        PR target/34312
        * gcc.target/i386/pr34312.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr34312.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug rtl-optimization/34312] [4.3 regression] spill failure with -O2 -fPIC -march=pentium-m on i386
  2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
                   ` (9 preceding siblings ...)
  2007-12-05 16:01 ` uros at gcc dot gnu dot org
@ 2007-12-05 16:03 ` ubizjak at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: ubizjak at gmail dot com @ 2007-12-05 16:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from ubizjak at gmail dot com  2007-12-05 16:03 -------
Fixed.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2007-
                   |                            |12/msg00188.html
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2007-12-05 16:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-01 23:17 [Bug target/34312] New: spill failure with -O2 -fPIC -march=pentium-m on i386 christophe at saout dot de
2007-12-01 23:19 ` [Bug target/34312] " christophe at saout dot de
2007-12-03 11:25 ` ubizjak at gmail dot com
2007-12-03 11:28 ` [Bug target/34312] [4.3 regression] " ubizjak at gmail dot com
2007-12-03 13:45 ` [Bug rtl-optimization/34312] " ubizjak at gmail dot com
2007-12-03 15:16 ` bonzini at gnu dot org
2007-12-03 16:32 ` rguenth at gcc dot gnu dot org
2007-12-03 17:52 ` rask at gcc dot gnu dot org
2007-12-03 20:48 ` ebotcazou at gcc dot gnu dot org
2007-12-05 13:55 ` ubizjak at gmail dot com
2007-12-05 16:01 ` uros at gcc dot gnu dot org
2007-12-05 16:03 ` ubizjak at gmail dot com

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