While trying to debug PR 116747, I noticed there was no dump
saying what was done. So this adds the debug dump and it helps
debug what is going on in PR 116747 too.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

        * tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Add debug dump.

Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>
---
 gcc/tree-ssa-phiopt.cc | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index 7b12692237e..488b45015e9 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -3469,6 +3469,17 @@ cond_if_else_store_replacement_1 (basic_block then_bb, 
basic_block else_bb,
   then_locus = gimple_location (then_assign);
   else_locus = gimple_location (else_assign);
 
+  if (dump_file && (dump_flags & TDF_DETAILS))
+    {
+      fprintf(dump_file, "factoring out stores:\n\tthen:\n");
+      print_gimple_stmt (dump_file, then_assign, 0,
+                        TDF_VOPS|TDF_MEMSYMS);
+      fprintf(dump_file, "\telse:\n");
+      print_gimple_stmt (dump_file, else_assign, 0,
+                        TDF_VOPS|TDF_MEMSYMS);
+      fprintf (dump_file, "\n");
+    }
+
   /* Now we've checked the constraints, so do the transformation:
      1) Remove the stores.  */
   gsi = gsi_for_stmt (then_assign);
@@ -3490,6 +3501,16 @@ cond_if_else_store_replacement_1 (basic_block then_bb, 
basic_block else_bb,
   add_phi_arg (newphi, else_rhs, EDGE_SUCC (else_bb, 0), else_locus);
 
   new_stmt = gimple_build_assign (lhs, gimple_phi_result (newphi));
+  if (dump_file && (dump_flags & TDF_DETAILS))
+    {
+      fprintf(dump_file, "to use phi:\n");
+      print_gimple_stmt (dump_file, newphi, 0,
+                        TDF_VOPS|TDF_MEMSYMS);
+      fprintf(dump_file, "\n");
+      print_gimple_stmt (dump_file, new_stmt, 0,
+                        TDF_VOPS|TDF_MEMSYMS);
+      fprintf(dump_file, "\n\n");
+    }
 
   /* 3) Insert that PHI node.  */
   gsi = gsi_after_labels (join_bb);
-- 
2.43.0

Reply via email to