Patchwork [graphite] Fix miscompiles for gromacs and gamess in graphite branch

login
register
mail settings
Submitter Sebastian Pop
Date June 25, 2010, 3:36 a.m.
Message ID <AANLkTim94C4a9QdRtAT-t-BwCC7uWGn5pHoNxup1KqZo@mail.gmail.com>
Download mbox | patch
Permalink /patch/56886/
State New
Headers show

Comments

Sebastian Pop - June 25, 2010, 3:36 a.m.
Hi,

I committed the attached patches to fix the miscompiles of two cpu2006
benchmarks, and apparently a bootstrap problem due to a previous patch
committed with some dead code, thanks Vladimir for reporting this.

0001 is another small step towards eliminating the uses of rename_map.

Sebastian Pop
--
AMD / Open Source Compiler Engineering / GNU Tools

Patch

From 3b7c4a659f453fdf433e8ef5852313d834619015 Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Thu, 24 Jun 2010 22:14:19 -0500
Subject: [PATCH 5/5] Fix 416.gamess miscompile: special case the rewrite of degenerate phi nodes.

2010-06-24  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-sese-to-poly.c (rewrite_degenerate_phi): New.
	(rewrite_reductions_out_of_ssa): Call it for degenerate_phi_result.
---
 gcc/ChangeLog.graphite      |    5 +++++
 gcc/graphite-sese-to-poly.c |   40 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index f1fc3ab..0b38c43 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,10 @@ 
 2010-06-24  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-sese-to-poly.c (rewrite_degenerate_phi): New.
+	(rewrite_reductions_out_of_ssa): Call it for degenerate_phi_result.
+
+2010-06-24  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-sese-to-poly.c (rewrite_cross_bb_phi_deps): Call
 	rewrite_close_phi_out_of_ssa.
 
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 9a02ba8..6514b48 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2271,6 +2271,37 @@  rewrite_phi_out_of_ssa (gimple_stmt_iterator *psi)
   gsi_insert_seq_before (&gsi, stmts, GSI_NEW_STMT);
 }
 
+/* Rewrite the degenerate phi node at position PSI from the degenerate
+   form "x = phi (y, y, ..., y)" to "x = y".  */
+
+static void
+rewrite_degenerate_phi (gimple_stmt_iterator *psi)
+{
+  tree rhs;
+  gimple stmt;
+  gimple_stmt_iterator gsi;
+  gimple phi = gsi_stmt (*psi);
+  tree res = gimple_phi_result (phi);
+  basic_block bb;
+
+  if (!is_gimple_reg (res))
+    {
+      gsi_next (psi);
+      return;
+    }
+
+  bb = gimple_bb (phi);
+  rhs = degenerate_phi_result (phi);
+  gcc_assert (rhs);
+
+  stmt = gimple_build_assign (res, rhs);
+  remove_phi_node (psi, false);
+  SSA_NAME_DEF_STMT (res) = stmt;
+
+  gsi = gsi_after_labels (bb);
+  gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
+}
+
 /* Rewrite out of SSA all the reduction phi nodes of SCOP.  */
 
 void
@@ -2284,8 +2315,15 @@  rewrite_reductions_out_of_ssa (scop_p scop)
     if (bb_in_sese_p (bb, region))
       for (psi = gsi_start_phis (bb); !gsi_end_p (psi);)
 	{
-	  if (scalar_close_phi_node_p (gsi_stmt (psi)))
+	  gimple phi = gsi_stmt (psi);
+
+	  if (gimple_phi_num_args (phi) > 1
+	      && degenerate_phi_result (phi))
+	    rewrite_degenerate_phi (&psi);
+
+	  else if (scalar_close_phi_node_p (phi))
 	    rewrite_close_phi_out_of_ssa (&psi);
+
 	  else if (reduction_phi_p (region, &psi))
 	    rewrite_phi_out_of_ssa (&psi);
 	}
-- 
1.7.0.4