]> gcc.gnu.org Git - gcc.git/commitdiff
re PR rtl-optimization/69307 (wrong code with -O2 -fselective-scheduling @ armv7a)
authorAndrey Belevantsev <abel@ispras.ru>
Sat, 12 Mar 2016 17:12:29 +0000 (20:12 +0300)
committerJeff Law <law@gcc.gnu.org>
Sat, 12 Mar 2016 17:12:29 +0000 (10:12 -0700)
PR rtl-optimization/69307
* sel-sched.c (choose_best_pseudo_reg): Properly check for hard
registers in modes that span more than one register.

PR rtl-optimization/69307
* gcc.dg/pr69307.c: New test.

From-SVN: r234163

gcc/ChangeLog
gcc/sel-sched.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr69307.c [new file with mode: 0644]

index 7d73d32bb011daad94d1c6fef809441d86bde188..6c41cf02c61500e33b05814ba9ecdab91da456a3 100644 (file)
@@ -1,3 +1,9 @@
+2016-03-12  Andrey Belevantsev  <abel@ispras.ru>
+
+       PR rtl-optimization/69307
+       * sel-sched.c (choose_best_pseudo_reg): Properly check for hard
+       registers in modes that span more than one register.
+
 2016-03-12  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR target/69614
index bd32ab5c154bec19fa6d3555dad29988843f1632..09cf0284603819fbdf06ef2a125670518ef47442 100644 (file)
@@ -1457,31 +1457,44 @@ choose_best_pseudo_reg (regset used_regs,
         gcc_assert (mode == GET_MODE (dest));
       orig_regno = REGNO (dest);
 
-      if (!REGNO_REG_SET_P (used_regs, orig_regno))
-        {
-          if (orig_regno < FIRST_PSEUDO_REGISTER)
-            {
-              gcc_assert (df_regs_ever_live_p (orig_regno));
+      /* Check that nothing in used_regs intersects with orig_regno.  When
+        we have a hard reg here, still loop over hard_regno_nregs.  */
+      if (HARD_REGISTER_NUM_P (orig_regno))
+       {
+         int j, n;
+         for (j = 0, n = hard_regno_nregs[orig_regno][mode]; j < n; j++)
+           if (REGNO_REG_SET_P (used_regs, orig_regno + j))
+             break;
+         if (j < n)
+           continue;
+       }
+      else
+       {
+         if (REGNO_REG_SET_P (used_regs, orig_regno))
+           continue;
+       }
+      if (HARD_REGISTER_NUM_P (orig_regno))
+       {
+         gcc_assert (df_regs_ever_live_p (orig_regno));
 
-              /* For hard registers, we have to check hardware imposed
-                 limitations (frame/stack registers, calls crossed).  */
-              if (!TEST_HARD_REG_BIT (reg_rename_p->unavailable_hard_regs,
-                                      orig_regno))
-               {
-                 /* Don't let register cross a call if it doesn't already
-                    cross one.  This condition is written in accordance with
-                    that in sched-deps.c sched_analyze_reg().  */
-                 if (!reg_rename_p->crosses_call
-                     || REG_N_CALLS_CROSSED (orig_regno) > 0)
-                   return gen_rtx_REG (mode, orig_regno);
-               }
+         /* For hard registers, we have to check hardware imposed
+            limitations (frame/stack registers, calls crossed).  */
+         if (!TEST_HARD_REG_BIT (reg_rename_p->unavailable_hard_regs,
+                                 orig_regno))
+           {
+             /* Don't let register cross a call if it doesn't already
+                cross one.  This condition is written in accordance with
+                that in sched-deps.c sched_analyze_reg().  */
+             if (!reg_rename_p->crosses_call
+                 || REG_N_CALLS_CROSSED (orig_regno) > 0)
+               return gen_rtx_REG (mode, orig_regno);
+           }
 
-              bad_hard_regs = true;
-            }
-          else
-            return dest;
-        }
-     }
+         bad_hard_regs = true;
+       }
+      else
+       return dest;
+    }
 
   *is_orig_reg_p_ptr = false;
 
index 4ef53c485fbd92440f2882995bc317e37e860cd1..13347121ea52c81f1ff7abc86290ce24ea1ed361 100644 (file)
@@ -1,3 +1,8 @@
+2016-03-12  Andrey Belevantsev  <abel@ispras.ru>
+
+       PR rtl-optimization/69307
+       * gcc.dg/pr69307.c: New test.
+
 2016-03-12  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR target/69614
diff --git a/gcc/testsuite/gcc.dg/pr69307.c b/gcc/testsuite/gcc.dg/pr69307.c
new file mode 100644 (file)
index 0000000..d9d343e
--- /dev/null
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fselective-scheduling2" } */
+
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long int uint64_t;
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+u64 __attribute__((noinline, noclone))
+foo(u8 u8_0, u16 u16_0, u32 u32_0, u64 u64_0, u8 u8_1, u16 u16_1, u32 u32_1, u64 u64_1, u8 u8_2, u16 u16_2, u32 u32_2, u64 u64_2, u8 u8_3, u16 u16_3, u32 u32_3, u64 u64_3)
+{
+ u8 *p8_2 = &u8_2;
+ u16 *p16_2 = &u16_2;
+ u8 *p8_3 = &u8_3;
+ u64 *p64_3 = &u64_3;
+ p8_2 = &u8_3;
+ *p8_3 -= *p64_3;
+ *p8_2 = (u64)*p8_2 % ((u64)*p8_2 | 3);
+ u8_2 = (u64)u8_2 / ((u64)*p16_2 | 1);
+ u16_0 = (u64)u16_0 % ((u64)*p8_2 | 3);
+ return u8_0 + u16_0 + u32_0 + u64_0 + u8_1 + u16_1 + u32_1 + u64_1 + u8_2 + u16_2 + u32_2 + u64_2 + u8_3 + u16_3 + u32_3 + u64_3;
+}
+int main()
+{
+ u64 x = 0;
+ x += foo(3llu, 6llu, 15llu, 28llu, 5llu, 11llu, 20llu, 44llu, 7llu, 10llu, 20llu, 55llu, 0llu, 9llu, 17llu, 48llu);
+ if (x != 0x1f3)
+        __builtin_abort();
+ return 0;
+}
+
This page took 0.404088 seconds and 5 git commands to generate.