PR rtl-optimization/54455
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Sep 2012 07:29:12 +0000 (07:29 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Sep 2012 07:29:12 +0000 (07:29 +0000)
* sel-sched-ir.c (maybe_tidy_empty_bb): Give up if previous fallthru
bb ends up with asm goto referencing bb's label.

* gcc.dg/54455.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191013 138bc75d-0d04-0410-961f-82ee72b054a4

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

index be5aeeb..ca50124 100644 (file)
@@ -1,3 +1,9 @@
+2012-09-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/54455
+       * sel-sched-ir.c (maybe_tidy_empty_bb): Give up if previous fallthru
+       bb ends up with asm goto referencing bb's label.
+
 2012-09-06  Chen Liqin  <liqin.gcc@gmail.com>
 
        * config/score/score.c: Remove TARGET_LEGITIMIZE_ADDRESS define
index 9b616c2..d237a24 100644 (file)
@@ -1,4 +1,4 @@
-2012-09-06  Tobias Burnus
+2012-09-06  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/54463
        * trans-intrinsic.c (gfc_conv_intrinsic_funcall): Fix matmul
index 449efc9..1f1095e 100644 (file)
@@ -1,5 +1,5 @@
 /* Instruction scheduling pass.  Selective scheduler and pipeliner.
-   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
+   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -3686,6 +3686,22 @@ maybe_tidy_empty_bb (basic_block bb)
   FOR_EACH_EDGE (e, ei, bb->preds)
     if (e->flags & EDGE_COMPLEX)
       return false;
+    else if (e->flags & EDGE_FALLTHRU)
+      {
+       rtx note;
+       /* If prev bb ends with asm goto, see if any of the
+          ASM_OPERANDS_LABELs don't point to the fallthru
+          label.  Do not attempt to redirect it in that case.  */
+       if (JUMP_P (BB_END (e->src))
+           && (note = extract_asm_operands (PATTERN (BB_END (e->src)))))
+         {
+           int i, n = ASM_OPERANDS_LABEL_LENGTH (note);
+
+           for (i = 0; i < n; ++i)
+             if (XEXP (ASM_OPERANDS_LABEL (note, i), 0) == BB_HEAD (bb))
+               return false;
+         }
+      }
 
   free_data_sets (bb);
 
index 7089b59..8589e9e 100644 (file)
@@ -1,4 +1,9 @@
-2012-09-06  Tobias Burnus
+2012-09-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/54455
+       * gcc.dg/54455.c: New test.
+
+2012-09-06  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/54463
        * gfortran.dg/promotion_2.f90: New.
diff --git a/gcc/testsuite/gcc.dg/54455.c b/gcc/testsuite/gcc.dg/54455.c
new file mode 100644 (file)
index 0000000..de68a53
--- /dev/null
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/54455 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fschedule-insns -fselective-scheduling --param max-sched-extend-regions-iters=2" } */
+
+extern void fn1 (void), fn2 (void);
+
+static inline __attribute__((always_inline)) int
+foo (int *x, long y)
+{
+  asm goto ("" : : "r" (x), "r" (y) : "memory" : lab);
+  return 0;
+lab:
+  return 1;
+}
+
+void
+bar (int *x)
+{
+  if (foo (x, 23))
+    fn1 ();
+  else
+    fn2 ();
+
+  foo (x, 2);
+}