This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][match-and-simplify] Robusten gimple_build against non-SSA context


We fold stmts from non-SSA so when we simplify a single stmt
into multiple ones (like strcat (x, "foo") -> memcpy (x + strlen ("foo"), 
....)) then gimple_build fails because it unconditionally builds
SSA names.

Fixed.

Richard.

2014-08-06  Richard Biener  <rguenther@suse.de>

	* gimple-fold.c (gimple_build): Allow to be called from
	non-SSA context.

Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c	(revision 213651)
+++ gcc/gimple-fold.c	(working copy)
@@ -3733,7 +3733,10 @@ gimple_build (gimple_seq *seq, location_
   tree res = gimple_simplify (code, type, op0, seq, valueize);
   if (!res)
     {
-      res = make_ssa_name (type, NULL);
+      if (gimple_in_ssa_p (cfun))
+	res = make_ssa_name (type, NULL);
+      else
+	res = create_tmp_reg (type, NULL);
       gimple stmt;
       if (code == REALPART_EXPR
 	  || code == IMAGPART_EXPR
@@ -3763,7 +3766,10 @@ gimple_build (gimple_seq *seq, location_
   tree res = gimple_simplify (code, type, op0, op1, seq, valueize);
   if (!res)
     {
-      res = make_ssa_name (type, NULL);
+      if (gimple_in_ssa_p (cfun))
+	res = make_ssa_name (type, NULL);
+      else
+	res = create_tmp_reg (type, NULL);
       gimple stmt = gimple_build_assign_with_ops (code, res, op0, op1);
       gimple_set_location (stmt, loc);
       gimple_seq_add_stmt_without_update (seq, stmt);
@@ -3787,7 +3793,10 @@ gimple_build (gimple_seq *seq, location_
 			      seq, valueize);
   if (!res)
     {
-      res = make_ssa_name (type, NULL);
+      if (gimple_in_ssa_p (cfun))
+	res = make_ssa_name (type, NULL);
+      else
+	res = create_tmp_reg (type, NULL);
       gimple stmt;
       if (code == BIT_FIELD_REF)
 	stmt = gimple_build_assign_with_ops (code, res,
@@ -3816,7 +3825,10 @@ gimple_build (gimple_seq *seq, location_
   tree res = gimple_simplify (fn, type, arg0, seq, valueize);
   if (!res)
     {
-      res = make_ssa_name (type, NULL);
+      if (gimple_in_ssa_p (cfun))
+	res = make_ssa_name (type, NULL);
+      else
+	res = create_tmp_reg (type, NULL);
       tree decl = builtin_decl_implicit (fn);
       gimple stmt = gimple_build_call (decl, 1, arg0);
       gimple_call_set_lhs (stmt, res);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]