PR middle-end/47530
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Jun 2012 16:51:24 +0000 (16:51 +0000)
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Jun 2012 16:51:24 +0000 (16:51 +0000)
        * trans-mem.c (expand_block_edges): Do not skip the first
        statement when resetting the BB.

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

gcc/ChangeLog
gcc/testsuite/g++.dg/tm/pr47530-2.C [new file with mode: 0644]
gcc/trans-mem.c

index c77ccda..174c1c1 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-04  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR middle-end/47530
+       * trans-mem.c (expand_block_edges): Do not skip the first
+       statement when resetting the BB.
+
 2012-06-04  Richard Guenther  <rguenther@suse.de>
 
        * tree-data-ref.c (stores_from_loop): Remove.
diff --git a/gcc/testsuite/g++.dg/tm/pr47530-2.C b/gcc/testsuite/g++.dg/tm/pr47530-2.C
new file mode 100644 (file)
index 0000000..c98e07e
--- /dev/null
@@ -0,0 +1,35 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O2 -fno-inline -fdump-tree-tmedge" }
+
+class RBTree
+{
+    struct RBNode
+    {
+      RBNode* next;
+    };
+
+  public:
+    RBNode* sentinel;
+    __attribute__((transaction_safe)) bool lookup();
+};
+
+bool RBTree::lookup()
+{
+  RBNode* x = sentinel;
+  while (x)
+    x = x->next;
+  return false;
+}
+
+
+RBTree* SET;
+
+void bench_test()
+{
+  __transaction_atomic { 
+      SET->lookup();
+    }
+}
+
+// { dg-final { scan-tree-dump-times "ITM_commitTransaction.*tail call" 0 "tmedge" } }
+// { dg-final { cleanup-tree-dump "tmedge" } }
index 7026823..5aae8b2 100644 (file)
@@ -2591,6 +2591,7 @@ expand_block_edges (struct tm_region *region, basic_block bb)
 
   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
     {
+      bool do_next = true;
       gimple stmt = gsi_stmt (gsi);
 
       /* ??? TM_COMMIT (and any other tm builtin function) in a nested
@@ -2612,6 +2613,7 @@ expand_block_edges (struct tm_region *region, basic_block bb)
              make_tm_edge (stmt, bb, region);
              bb = e->dest;
              gsi = gsi_start_bb (bb);
+             do_next = false;
            }
 
          /* Delete any tail-call annotation that may have been added.
@@ -2620,7 +2622,8 @@ expand_block_edges (struct tm_region *region, basic_block bb)
          gimple_call_set_tail (stmt, false);
        }
 
-      gsi_next (&gsi);
+      if (do_next)
+       gsi_next (&gsi);
     }
 }