This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, i386]: Fix PR target/34312; spill failure with -O2 -fPIC -march=pentium-m on i386
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Richard Guenther <rguenther at suse dot de>, Jan Hubicka <jh at suse dot cz>, Paolo Bonzini <bonzini at gnu dot org>, Eric Botcazou <ebotcazou at libertysurf dot fr>
- Date: Wed, 05 Dec 2007 16:08:11 +0100
- Subject: [PATCH, i386]: Fix PR target/34312; spill failure with -O2 -fPIC -march=pentium-m on i386
Hello!
The problem exposed by the testcase in PR target/34312 is, that due to
implicit regparm function call register usage (%eax, %edx, %ecx) and
-fpic usage of (%ebx), register allocator runs out of registers to
allocate another QImode value.
There already exists the functionality, where implicit regparm value is
lowered due to increased register pressure caused by global_regs usage.
However, register pressure is also increased by fixed_regs in similar
way (they are not available to register allocator), so it is somehow
logical, that fixed_regs registers should be handled here in the same
way as global regs.
Patch was bootstrapped on x86_64-pc-linux-gnu and regression tested on
x86_64 with and without -m32. Patch is committed to SVN.
2007-12-05 Uros Bizjak <ubizjak@gmail.com>
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:
2007-12-05 Uros Bizjak <ubizjak@gmail.com>
PR target/34312
* gcc.target/i386/pr34312.c: New test.
Uros.
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c (revision 130622)
+++ config/i386/i386.c (working copy)
@@ -3198,9 +3198,9 @@ ix86_function_regparm (const_tree type,
struct function *f;
/* Make sure no regparm register is taken by a
- global register variable. */
+ fixed register or 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
@@ -3222,11 +3222,12 @@ ix86_function_regparm (const_tree type,
TYPE_ATTRIBUTES (TREE_TYPE (decl)))))
local_regparm = 2;
- /* Each global register variable increases register preassure,
- so the more global reg vars there are, the smaller regparm
- optimization use, unless requested by the user explicitly. */
+ /* Each global register variable or fixed register usage
+ increases register pressure, so less registers should be
+ used for argument passing. This functionality can be
+ overriden by explicit regparm value. */
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;
Index: testsuite/gcc.target/i386/pr34312.c
===================================================================
--- testsuite/gcc.target/i386/pr34312.c (revision 0)
+++ testsuite/gcc.target/i386/pr34312.c (revision 0)
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-O2 -march=pentium-m -fpic" } */
+
+typedef struct
+{
+ unsigned char seq[3];
+} JamoNormMap;
+
+static const JamoNormMap *
+JamoClusterSearch (JamoNormMap aKey, const JamoNormMap * aClusters,
+ short aClustersSize)
+{
+ unsigned short l = 0, u = aClustersSize - 1;
+ unsigned short h = (l + u) / 2;
+
+ if ((aKey.seq[1] - aClusters[h].seq[1]) < 0)
+ return JamoClusterSearch (aKey, &(aClusters[l]), h - l);
+}
+
+short
+JamoSrchReplace (const JamoNormMap * aClusters, unsigned short aClustersSize,
+ unsigned short * aIn, unsigned int * aLength,
+ unsigned short aOffset)
+{
+ JamoNormMap key;
+
+ key.seq[0] = 0;
+ key.seq[1] = 1;
+ key.seq[2] = 2;
+
+ JamoClusterSearch (key, aClusters, aClustersSize);
+}