]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/37483 (Segfault in noce_try_sign_mask (ifcvt.c): b_unconditional)
authorJakub Jelinek <jakub@redhat.com>
Tue, 16 Sep 2008 22:15:49 +0000 (00:15 +0200)
committerAdam Nemet <nemet@gcc.gnu.org>
Tue, 16 Sep 2008 22:15:49 +0000 (22:15 +0000)
PR rtl-optimization/37483
* ifcvt.c (noce_try_sign_mask): Use if_info->test_bb instead of
if_info->insn_b's bb as argument to optimize_bb_for_speed_p.
Rearrange code to better match the original comment.  Check
t_unconditional first.  Improve comment.

testsuite/
* gcc.c-torture/compile/pr37483.c: New test.
* gcc.c-torture/compile/pr37395.c: New test.

Co-Authored-By: Adam Nemet <anemet@caviumnetworks.com>
From-SVN: r140403

gcc/ChangeLog
gcc/ifcvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr37395.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr37483.c [new file with mode: 0644]

index c4d91b6c901fa261f0c838265f157be88bff39e5..e6238c23a97ce4c8853c133884c840b1583aeabf 100644 (file)
@@ -1,3 +1,12 @@
+2008-09-16  Jakub Jelinek  <jakub@redhat.com>
+           Adam Nemet  <anemet@caviumnetworks.com>
+
+       PR rtl-optimization/37483
+       * ifcvt.c (noce_try_sign_mask): Use if_info->test_bb instead of
+       if_info->insn_b's bb as argument to optimize_bb_for_speed_p.
+       Rearrange code to better match the original comment.  Check
+       t_unconditional first.  Improve comment.
+
 2008-09-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/37529
index 66a65a4a7ab34b817150271ac6ea20b016eb0d2d..341174ab02fe08773491efc30a00d41a0a679b12 100644 (file)
@@ -1869,7 +1869,7 @@ noce_try_sign_mask (struct noce_if_info *if_info)
   rtx cond, t, m, c, seq;
   enum machine_mode mode;
   enum rtx_code code;
-  bool b_unconditional;
+  bool t_unconditional;
 
   cond = if_info->cond;
   code = GET_CODE (cond);
@@ -1898,16 +1898,19 @@ noce_try_sign_mask (struct noce_if_info *if_info)
   if (GET_MODE (m) != mode)
     return FALSE;
 
-  /* This is only profitable if T is cheap, or T is unconditionally
-     executed/evaluated in the original insn sequence.  The latter
-     happens if INSN_B was taken from TEST_BB, or if there was no
-     INSN_B which can happen for e.g. conditional stores to memory.  */
-  b_unconditional = (if_info->insn_b == NULL_RTX
-                    || BLOCK_FOR_INSN (if_info->insn_b) == if_info->test_bb);
-  if (rtx_cost (t, SET, optimize_bb_for_speed_p (BLOCK_FOR_INSN (if_info->insn_b)))
-      >= COSTS_N_INSNS (2)
-      && (!b_unconditional
-          || t != if_info->b))
+  /* This is only profitable if T is unconditionally executed/evaluated in the
+     original insn sequence or T is cheap.  The former happens if B is the
+     non-zero (T) value and if INSN_B was taken from TEST_BB, or there was no
+     INSN_B which can happen for e.g. conditional stores to memory.  For the
+     cost computation use the block TEST_BB where the evaluation will end up
+     after the transformation.  */
+  t_unconditional =
+    (t == if_info->b
+     && (if_info->insn_b == NULL_RTX
+        || BLOCK_FOR_INSN (if_info->insn_b) == if_info->test_bb));
+  if (!(t_unconditional
+       || (rtx_cost (t, SET, optimize_bb_for_speed_p (if_info->test_bb))
+           < COSTS_N_INSNS (2))))
     return FALSE;
 
   start_sequence ();
index 84d62d873e3146257ce649b3532cc74e316383c2..f1763d47fc7b113b45d2414183cd55e432a53272 100644 (file)
@@ -1,3 +1,10 @@
+2008-09-16  Jakub Jelinek  <jakub@redhat.com>
+           Adam Nemet  <anemet@caviumnetworks.com>
+
+       PR rtl-optimization/37483
+       * gcc.c-torture/compile/pr37483.c: New test.
+       * gcc.c-torture/compile/pr37395.c: New test.
+
 2008-09-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/37529
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37395.c b/gcc/testsuite/gcc.c-torture/compile/pr37395.c
new file mode 100644 (file)
index 0000000..e15b154
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR target/37395 */
+
+int
+f (int j)
+{
+  int i;
+  asm volatile ("" : "=r"(i));
+  if (i >= 0)
+    j = 0;
+  return j;
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37483.c b/gcc/testsuite/gcc.c-torture/compile/pr37483.c
new file mode 100644 (file)
index 0000000..b094892
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR target/37483 */
+
+unsigned long long
+foo (unsigned count, int i)
+{
+  unsigned long long value;
+  if (i == 0)
+    value = (value & 0xFFFFFFFF) >> count;
+  return value;
+}