One more fix for PR 91333 - suboptimal register allocation for inline asm
authorVladimir N. Makarov <vmakarov@redhat.com>
Sun, 2 Feb 2020 16:23:25 +0000 (11:23 -0500)
committerVladimir N. Makarov <vmakarov@redhat.com>
Sun, 2 Feb 2020 16:27:47 +0000 (11:27 -0500)
2020-02-02  Vladimir Makarov  <vmakarov@redhat.com>

PR rtl-optimization/91333
* ira-color.c (struct allocno_color_data): Add member
hard_reg_prefs.
(init_allocno_threads): Set the member up.
(bucket_allocno_compare_func): Add compare hard reg
prefs.

2020-02-02  Vladimir Makarov  <vmakarov@redhat.com>

PR rtl-optimization/91333
* gcc.target/i386/pr91333.c: Add vmovsd to regexp.  Set up count
to 3.

gcc/ChangeLog
gcc/ira-color.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr91333.c

index b2031ee..3c0f117 100644 (file)
@@ -1,3 +1,12 @@
+2020-02-02  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR rtl-optimization/91333
+       * ira-color.c (struct allocno_color_data): Add member
+       hard_reg_prefs.
+       (init_allocno_threads): Set the member up.
+       (bucket_allocno_compare_func): Add compare hard reg
+       prefs.
+
 2020-01-31  Sandra Loosemore  <sandra@codesourcery.com>
 
        nios2: Support for GOT-relative DW_EH_PE_datarel encoding.
index 51c4afd..444cb1e 100644 (file)
@@ -151,6 +151,8 @@ struct allocno_color_data
   ira_allocno_t next_thread_allocno;
   /* All thread frequency.  Defined only for first thread allocno.  */
   int thread_freq;
+  /* Sum of frequencies of hard register preferences of the allocno.  */
+  int hard_reg_prefs;
 };
 
 /* See above.  */
@@ -2173,6 +2175,7 @@ init_allocno_threads (void)
   ira_allocno_t a;
   unsigned int j;
   bitmap_iterator bi;
+  ira_pref_t pref;
 
   EXECUTE_IF_SET_IN_BITMAP (consideration_allocno_bitmap, 0, j, bi)
     {
@@ -2181,6 +2184,9 @@ init_allocno_threads (void)
       ALLOCNO_COLOR_DATA (a)->first_thread_allocno
        = ALLOCNO_COLOR_DATA (a)->next_thread_allocno = a;
       ALLOCNO_COLOR_DATA (a)->thread_freq = ALLOCNO_FREQ (a);
+      ALLOCNO_COLOR_DATA (a)->hard_reg_prefs = 0;
+      for (pref = ALLOCNO_PREFS (a); pref != NULL; pref = pref->next_pref)
+       ALLOCNO_COLOR_DATA (a)->hard_reg_prefs += pref->freq;
     }
 }
 
@@ -2251,6 +2257,11 @@ bucket_allocno_compare_func (const void *v1p, const void *v2p)
   ira_allocno_t t2 = ALLOCNO_COLOR_DATA (a2)->first_thread_allocno;
   int cl1 = ALLOCNO_CLASS (a1), cl2 = ALLOCNO_CLASS (a2);
 
+  /* Push allocnos with minimal hard_reg_prefs first.  */
+  pref1 = ALLOCNO_COLOR_DATA (a1)->hard_reg_prefs;
+  pref2 = ALLOCNO_COLOR_DATA (a2)->hard_reg_prefs;
+  if ((diff = pref1 - pref2) != 0)
+    return diff;
   /* Push allocnos with minimal conflict_allocno_hard_prefs first.  */
   pref1 = ALLOCNO_COLOR_DATA (a1)->conflict_allocno_hard_prefs;
   pref2 = ALLOCNO_COLOR_DATA (a2)->conflict_allocno_hard_prefs;
index 5902ab6..779f1fb 100644 (file)
@@ -1,3 +1,9 @@
+2020-02-02  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR rtl-optimization/91333
+       * gcc.target/i386/pr91333.c: Add vmovsd to regexp.  Set up count
+       to 3.
+
 2020-01-31  Sandra Loosemore  <sandra@codesourcery.com>
 
        nios2: Support for GOT-relative DW_EH_PE_datarel encoding.
index 41fc328..2694912 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do compile { target x86_64-*-* } } */
 /* { dg-options "-O2 -mavx" } */
-/* { dg-final { scan-assembler-times "vmovapd" 2 } } */
+/* { dg-final { scan-assembler-times "vmovapd|vmovsd" 3 } } */
 
 static inline double g (double x){
   asm volatile ("" : "+x" (x));