diff mbox

[match-and-simplify] Fix call handling

Message ID alpine.LSU.2.11.1405141217230.18709@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener May 14, 2014, 10:17 a.m. UTC
This fixes call handling.

Committed to the branch.

Richard.

2014-05-14  Richard Biener  <rguenther@suse.de>

	* gimple-match-head.c (maybe_push_res_to_seq): Fix res
	!= NULL case and add a comment.
	(gimple_match_and_simplify): Properly handle virtual
	operands when we replace the stmt on the gsi interface.
diff mbox

Patch

Index: gcc/gimple-match-head.c
===================================================================
--- gcc/gimple-match-head.c	(revision 210353)
+++ gcc/gimple-match-head.c	(working copy)
@@ -218,13 +218,20 @@  gimple_resimplify3 (gimple_seq *seq,
 }
 
 
+/* Push the exploded expression described by RCODE, TYPE and OPS
+   as a statement to SEQ if necessary and return a gimple value
+   denoting the value of the expression.  If RES is not NULL
+   then the result will be always RES and even gimple values are
+   pushed to SEQ.  */
+
 static tree
 maybe_push_res_to_seq (code_helper rcode, tree type, tree *ops,
 		       gimple_seq *seq, tree res = NULL_TREE)
 {
   if (rcode.is_tree_code ())
     {
-      if (TREE_CODE_LENGTH ((tree_code) rcode) == 0
+      if (!res
+	  && TREE_CODE_LENGTH ((tree_code) rcode) == 0
 	  && is_gimple_val (ops[0]))
 	return ops[0];
       if (!seq)
@@ -544,7 +551,10 @@  gimple_match_and_simplify (gimple_stmt_i
       maybe_push_res_to_seq (rcode, TREE_TYPE (lhs),
 			     ops, &tail, lhs);
       gcc_assert (gimple_seq_singleton_p (tail));
-      gsi_replace (gsi, gimple_seq_first_stmt (tail), false);
+      gimple with = gimple_seq_first_stmt (tail);
+      gimple_set_vdef (with, gimple_vdef (stmt));
+      gimple_set_vuse (with, gimple_vuse (stmt));
+      gsi_replace (gsi, with, false);
     }
   else
     /* Handle for example GIMPLE_COND, etc.  */