[PATCH][GIMPLE FE] Handle non-SSA PHI args

Richard Biener rguenther@suse.de
Thu Oct 27 12:20:00 GMT 2016


Tested on x86_64-unknown-linux-gnu.

Richard.

2016-10-27  Richard Biener  <rguenther@suse.de>

	* tree-into-ssa.c (rewrite_add_phi_arguments): Handle non-SSA
	PHI arguments from the GIMPLE FE.

	* gcc.dg/gimplefe-18.c: New testcase.

diff --git a/gcc/testsuite/gcc.dg/gimplefe-18.c b/gcc/testsuite/gcc.dg/gimplefe-18.c
new file mode 100644
index 0000000..ba918b2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-18.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+int
+__GIMPLE () *
+foo ()
+{
+  int _1;
+  int j;
+  int *b;
+  _1 = 1;
+bb1:
+  if (_1)
+    goto bb3;
+  else
+    goto bb2;
+
+bb2:
+  b_2 = (int *)0;
+
+bb3:
+  b_4 = __PHI (bb1: &j, bb2: b_2);
+  return b_4;
+}
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 7eaf8ae..0e78845 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -1383,10 +1383,11 @@ rewrite_add_phi_arguments (basic_block bb)
 
 	  phi = gsi.phi ();
 	  res = gimple_phi_result (phi);
-	  /* If we have pre-existing PHI its args may be different
-	     vars than existing vars */
+	  /* If we have pre-existing PHI (via the GIMPLE FE) its args may
+	     be different vars than existing vars and they may be constants
+	     as well.  Note the following supports partial SSA for PHI args.  */
 	  argvar = gimple_phi_arg_def (phi, e->dest_idx);
-	  if (argvar && TREE_CODE (argvar) == SSA_NAME)
+	  if (argvar && ! DECL_P (argvar))
 	    continue;
 	  if (!argvar)
 	    argvar = SSA_NAME_VAR (res);



More information about the Gcc-patches mailing list