Patchwork patch to fix PR56348

login
register
mail settings
Submitter Vladimir Makarov
Date Feb. 15, 2013, 7:17 p.m.
Message ID <511E89D7.20002@redhat.com>
Download mbox | patch
Permalink /patch/220824/
State New
Headers show

Comments

Vladimir Makarov - Feb. 15, 2013, 7:17 p.m.
The following patch fixes PR56348.  The details of the problem are given on

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

The patch was successfully bootstrapped and tested on x86/x86-64.

Committed as rev. 196090.

2013-02-15  Vladimir Makarov  <vmakarov@redhat.com>

         PR rtl-optimization/56348
         * lra-assigns.c (reload_pseudo_compare_func): Prefer bigger 
pseudos.

2013-02-15  Vladimir Makarov  <vmakarov@redhat.com>

         PR rtl-optimization/56348
         * gcc.target/i386/pr56348.c: New test.

Patch

Index: lra-assigns.c
===================================================================
--- lra-assigns.c	(revision 196081)
+++ lra-assigns.c	(working copy)
@@ -197,6 +197,12 @@  reload_pseudo_compare_func (const void *
   if ((diff = (regno_assign_info[regno_assign_info[r2].first].freq
 	       - regno_assign_info[regno_assign_info[r1].first].freq)) != 0)
     return diff;
+  /* Allocate bigger pseudos first to avoid register file
+     fragmentation.  */
+  if ((diff
+       = (ira_reg_class_max_nregs[cl2][lra_reg_info[r2].biggest_mode]
+	  - ira_reg_class_max_nregs[cl1][lra_reg_info[r1].biggest_mode])) != 0)
+    return diff;
   /* Put pseudos from the thread nearby.  */
   if ((diff = regno_assign_info[r1].first - regno_assign_info[r2].first) != 0)
     return diff;
Index: testsuite/gcc.target/i386/pr56348.c
===================================================================
--- testsuite/gcc.target/i386/pr56348.c	(revision 0)
+++ testsuite/gcc.target/i386/pr56348.c	(working copy)
@@ -0,0 +1,38 @@ 
+/* PR target/56348 */
+/* { dg-do compile { target { ia32 } } } */
+/* { dg-options "-O2 -fPIC -mfpmath=sse -msse2" } */
+
+typedef unsigned int size_t;
+
+extern double fabs (double __x) __attribute__ ((__nothrow__, __leaf__))
+  __attribute__ ((__const__));
+
+typedef struct cholmod_sparse_struct
+{
+  size_t ncol;
+  void *p;
+} cholmod_sparse;
+
+int cholmod_l_reallocate_sparse (size_t, cholmod_sparse *, void *);
+
+int
+cholmod_l_drop (double tol, cholmod_sparse * A)
+{
+  double aij;
+  double *Ax;
+  long long *Ap, *Ai, *Anz;
+  long long packed, i, j, nrow, ncol, p, pend, nz, values;
+  Ap = A->p;
+  ncol = A->ncol;
+  nz = 0;
+  for (j = 0; j < ncol; j++)
+    for (; p < pend; p++)
+      {
+        i = Ai[p];
+        aij = Ax[p];
+        if (i <= j && (fabs (aij) > tol || ((aij) != (aij))))
+          nz++;
+      }
+  Ap[ncol] = nz;
+  cholmod_l_reallocate_sparse (nz, A, 0);
+}