+2012-08-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/50672
+       Revert
+       2012-08-01  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-tail-merge.c (release_last_vdef): Remove.
+       (replace_block_by): Adjust.
+
 2012-08-02  Richard Guenther  <rguenther@suse.de>
 
        * tree-dfa.c (referenced_var_lookup): Remove.
 
+2012-08-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/50672
+       * g++.dg/torture/pr50672.C: New testcase.
+
 2012-08-02  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/54147
 
--- /dev/null
+// { dg-do compile }
+
+struct A
+{
+  bool isHint();
+};
+class B
+{
+  void makeLine( int *) const;
+  void drawLine() const; A* to() const;
+  void _print() const;
+};
+A a;
+void  B::makeLine(int *p1) const
+{
+  if (a.isHint() && to()->isHint()) ;
+  else {
+      if (p1) B::drawLine(); else B::_print();
+      return;
+  }
+  if (p1) B::drawLine(); else B::_print();
+}
 
     same_succ_flush_bb (BASIC_BLOCK (i));
 }
 
+/* Release the last vdef in BB, either normal or phi result.  */
+
+static void
+release_last_vdef (basic_block bb)
+{
+  gimple_stmt_iterator i;
+
+  for (i = gsi_last_bb (bb); !gsi_end_p (i); gsi_prev_nondebug (&i))
+    {
+      gimple stmt = gsi_stmt (i);
+      if (gimple_vdef (stmt) == NULL_TREE)
+       continue;
+
+      mark_virtual_operand_for_renaming (gimple_vdef (stmt));
+      return;
+    }
+
+  for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i))
+    {
+      gimple phi = gsi_stmt (i);
+      tree res = gimple_phi_result (phi);
+
+      if (is_gimple_reg (res))
+       continue;
+
+      mark_virtual_phi_result_for_renaming (phi);
+      return;
+    }
+  
+}
+
 /* For deleted_bb_preds, find bbs with same successors.  */
 
 static void
   bb1->frequency = 0;
 
   /* Do updates that use bb1, before deleting bb1.  */
+  release_last_vdef (bb1);
   same_succ_flush_bb (bb1);
 
   delete_basic_block (bb1);