diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 4d4ef43cb36..f61bc87da63 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -8665,6 +8665,29 @@ gimple_build_valueize (tree op)
   return NULL_TREE;
 }
 
+/* Helper for gimple_build to perform the final insertion of stmts on SEQ.  */
+
+static inline void
+gimple_build_insert_seq (gimple_stmt_iterator *gsi,
+			 bool before, gsi_iterator_update update,
+			 gimple_seq seq)
+{
+  if (before)
+    {
+      if (gsi->bb)
+	gsi_insert_seq_before (gsi, seq, update);
+      else
+	gsi_insert_seq_before_without_update (gsi, seq, update);
+    }
+  else
+    {
+      if (gsi->bb)
+	gsi_insert_seq_after (gsi, seq, update);
+      else
+	gsi_insert_seq_after_without_update (gsi, seq, update);
+    }
+}
+
 /* Build the expression CODE OP0 of type TYPE with location LOC,
    simplifying it first if possible.  Returns the built
    expression value and inserts statements possibly defining it
@@ -8697,27 +8720,14 @@ gimple_build (gimple_stmt_iterator *gsi,
       gimple_set_location (stmt, loc);
       gimple_seq_add_stmt_without_update (&seq, stmt);
     }
-  if (before)
-    {
-      if (gsi->bb)
-	gsi_insert_seq_before (gsi, seq, update);
-      else
-	gsi_insert_seq_before_without_update (gsi, seq, update);
-    }
-  else
-    {
-      if (gsi->bb)
-	gsi_insert_seq_after (gsi, seq, update);
-      else
-	gsi_insert_seq_after_without_update (gsi, seq, update);
-    }
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build the expression OP0 CODE OP1 of type TYPE with location LOC,
    simplifying it first if possible.  Returns the built
-   expression value and appends statements possibly defining it
-   to SEQ.  */
+   expression value inserting any new statements at GSI honoring BEFORE
+   and UPDATE.  */
 
 tree
 gimple_build (gimple_stmt_iterator *gsi,
@@ -8736,27 +8746,14 @@ gimple_build (gimple_stmt_iterator *gsi,
       gimple_set_location (stmt, loc);
       gimple_seq_add_stmt_without_update (&seq, stmt);
     }
-  if (before)
-    {
-      if (gsi->bb)
-	gsi_insert_seq_before (gsi, seq, update);
-      else
-	gsi_insert_seq_before_without_update (gsi, seq, update);
-    }
-  else
-    {
-      if (gsi->bb)
-	gsi_insert_seq_after (gsi, seq, update);
-      else
-	gsi_insert_seq_after_without_update (gsi, seq, update);
-    }
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build the expression (CODE OP0 OP1 OP2) of type TYPE with location LOC,
    simplifying it first if possible.  Returns the built
-   expression value and appends statements possibly defining it
-   to SEQ.  */
+   expression value inserting any new statements at GSI honoring BEFORE
+   and UPDATE.  */
 
 tree
 gimple_build (gimple_stmt_iterator *gsi,
@@ -8781,31 +8778,22 @@ gimple_build (gimple_stmt_iterator *gsi,
       gimple_set_location (stmt, loc);
       gimple_seq_add_stmt_without_update (&seq, stmt);
     }
-  if (before)
-    {
-      if (gsi->bb)
-	gsi_insert_seq_before (gsi, seq, update);
-      else
-	gsi_insert_seq_before_without_update (gsi, seq, update);
-    }
-  else
-    {
-      if (gsi->bb)
-	gsi_insert_seq_after (gsi, seq, update);
-      else
-	gsi_insert_seq_after_without_update (gsi, seq, update);
-    }
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build the call FN () with a result of type TYPE (or no result if TYPE is
    void) with a location LOC.  Returns the built expression value (or NULL_TREE
-   if TYPE is void) and appends statements possibly defining it to SEQ.  */
+   if TYPE is void) inserting any new statements at GSI honoring BEFORE
+   and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, combined_fn fn, tree type)
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, combined_fn fn, tree type)
 {
   tree res = NULL_TREE;
+  gimple_seq seq = NULL;
   gcall *stmt;
   if (internal_fn_p (fn))
     stmt = gimple_build_call_internal (as_internal_fn (fn), 0);
@@ -8820,21 +8808,25 @@ gimple_build (gimple_seq *seq, location_t loc, combined_fn fn, tree type)
       gimple_call_set_lhs (stmt, res);
     }
   gimple_set_location (stmt, loc);
-  gimple_seq_add_stmt_without_update (seq, stmt);
+  gimple_seq_add_stmt_without_update (&seq, stmt);
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build the call FN (ARG0) with a result of type TYPE
    (or no result if TYPE is void) with location LOC,
    simplifying it first if possible.  Returns the built
-   expression value (or NULL_TREE if TYPE is void) and appends
-   statements possibly defining it to SEQ.  */
+   expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, combined_fn fn,
 	      tree type, tree arg0)
 {
-  tree res = gimple_simplify (fn, type, arg0, seq, gimple_build_valueize);
+  gimple_seq seq = NULL;
+  tree res = gimple_simplify (fn, type, arg0, &seq, gimple_build_valueize);
   if (!res)
     {
       gcall *stmt;
@@ -8851,22 +8843,27 @@ gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
 	  gimple_call_set_lhs (stmt, res);
 	}
       gimple_set_location (stmt, loc);
-      gimple_seq_add_stmt_without_update (seq, stmt);
+      gimple_seq_add_stmt_without_update (&seq, stmt);
     }
+  gimple_build_insert_seq  (gsi, before, update, seq);
   return res;
 }
 
 /* Build the call FN (ARG0, ARG1) with a result of type TYPE
    (or no result if TYPE is void) with location LOC,
    simplifying it first if possible.  Returns the built
-   expression value (or NULL_TREE if TYPE is void) and appends
-   statements possibly defining it to SEQ.  */
+   expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, combined_fn fn,
 	      tree type, tree arg0, tree arg1)
 {
-  tree res = gimple_simplify (fn, type, arg0, arg1, seq, gimple_build_valueize);
+  gimple_seq seq = NULL;
+  tree res = gimple_simplify (fn, type, arg0, arg1, &seq,
+			      gimple_build_valueize);
   if (!res)
     {
       gcall *stmt;
@@ -8883,23 +8880,27 @@ gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
 	  gimple_call_set_lhs (stmt, res);
 	}
       gimple_set_location (stmt, loc);
-      gimple_seq_add_stmt_without_update (seq, stmt);
+      gimple_seq_add_stmt_without_update (&seq, stmt);
     }
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build the call FN (ARG0, ARG1, ARG2) with a result of type TYPE
    (or no result if TYPE is void) with location LOC,
    simplifying it first if possible.  Returns the built
-   expression value (or NULL_TREE if TYPE is void) and appends
-   statements possibly defining it to SEQ.  */
+   expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, combined_fn fn,
 	      tree type, tree arg0, tree arg1, tree arg2)
 {
+  gimple_seq seq = NULL;
   tree res = gimple_simplify (fn, type, arg0, arg1, arg2,
-			      seq, gimple_build_valueize);
+			      &seq, gimple_build_valueize);
   if (!res)
     {
       gcall *stmt;
@@ -8917,92 +8918,107 @@ gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
 	  gimple_call_set_lhs (stmt, res);
 	}
       gimple_set_location (stmt, loc);
-      gimple_seq_add_stmt_without_update (seq, stmt);
+      gimple_seq_add_stmt_without_update (&seq, stmt);
     }
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build CODE (OP0) with a result of type TYPE (or no result if TYPE is
    void) with location LOC, simplifying it first if possible.  Returns the
-   built expression value (or NULL_TREE if TYPE is void) and appends
-   statements possibly defining it to SEQ.  */
+   built expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, code_helper code,
-	      tree type, tree op0)
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, code_helper code, tree type, tree op0)
 {
   if (code.is_tree_code ())
-    return gimple_build (seq, loc, tree_code (code), type, op0);
-  return gimple_build (seq, loc, combined_fn (code), type, op0);
+    return gimple_build (gsi, before, update, loc, tree_code (code), type, op0);
+  return gimple_build (gsi, before, update, loc, combined_fn (code), type, op0);
 }
 
 /* Build CODE (OP0, OP1) with a result of type TYPE (or no result if TYPE is
    void) with location LOC, simplifying it first if possible.  Returns the
-   built expression value (or NULL_TREE if TYPE is void) and appends
-   statements possibly defining it to SEQ.  */
+   built expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, code_helper code,
-	      tree type, tree op0, tree op1)
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, code_helper code, tree type, tree op0, tree op1)
 {
   if (code.is_tree_code ())
-    return gimple_build (seq, loc, tree_code (code), type, op0, op1);
-  return gimple_build (seq, loc, combined_fn (code), type, op0, op1);
+    return gimple_build (gsi, before, update,
+			 loc, tree_code (code), type, op0, op1);
+  return gimple_build (gsi, before, update,
+		       loc, combined_fn (code), type, op0, op1);
 }
 
 /* Build CODE (OP0, OP1, OP2) with a result of type TYPE (or no result if TYPE
    is void) with location LOC, simplifying it first if possible.  Returns the
-   built expression value (or NULL_TREE if TYPE is void) and appends statements
-   possibly defining it to SEQ.  */
+   built expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, code_helper code,
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, code_helper code,
 	      tree type, tree op0, tree op1, tree op2)
 {
   if (code.is_tree_code ())
-    return gimple_build (seq, loc, tree_code (code), type, op0, op1, op2);
-  return gimple_build (seq, loc, combined_fn (code), type, op0, op1, op2);
+    return gimple_build (gsi, before, update,
+			 loc, tree_code (code), type, op0, op1, op2);
+  return gimple_build (gsi, before, update,
+		       loc, combined_fn (code), type, op0, op1, op2);
 }
 
 /* Build the conversion (TYPE) OP with a result of type TYPE
    with location LOC if such conversion is neccesary in GIMPLE,
    simplifying it first.
-   Returns the built expression value and appends
-   statements possibly defining it to SEQ.  */
+   Returns the built expression inserting any new statements
+   at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
+gimple_convert (gimple_stmt_iterator *gsi,
+		bool before, gsi_iterator_update update,
+		location_t loc, tree type, tree op)
 {
   if (useless_type_conversion_p (type, TREE_TYPE (op)))
     return op;
-  return gimple_build (seq, loc, NOP_EXPR, type, op);
+  return gimple_build (gsi, before, update, loc, NOP_EXPR, type, op);
 }
 
 /* Build the conversion (ptrofftype) OP with a result of a type
    compatible with ptrofftype with location LOC if such conversion
    is neccesary in GIMPLE, simplifying it first.
-   Returns the built expression value and appends
-   statements possibly defining it to SEQ.  */
+   Returns the built expression value inserting any new statements
+   at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_convert_to_ptrofftype (gimple_seq *seq, location_t loc, tree op)
+gimple_convert_to_ptrofftype (gimple_stmt_iterator *gsi,
+			      bool before, gsi_iterator_update update,
+			      location_t loc, tree op)
 {
   if (ptrofftype_p (TREE_TYPE (op)))
     return op;
-  return gimple_convert (seq, loc, sizetype, op);
+  return gimple_convert (gsi, before, update, loc, sizetype, op);
 }
 
 /* Build a vector of type TYPE in which each element has the value OP.
-   Return a gimple value for the result, appending any new statements
-   to SEQ.  */
+   Return a gimple value for the result, inserting any new statements
+   at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build_vector_from_val (gimple_seq *seq, location_t loc, tree type,
-			      tree op)
+gimple_build_vector_from_val (gimple_stmt_iterator *gsi,
+			      bool before, gsi_iterator_update update,
+			      location_t loc, tree type, tree op)
 {
   if (!TYPE_VECTOR_SUBPARTS (type).is_constant ()
       && !CONSTANT_CLASS_P (op))
-    return gimple_build (seq, loc, VEC_DUPLICATE_EXPR, type, op);
+    return gimple_build (gsi, before, update,
+			 loc, VEC_DUPLICATE_EXPR, type, op);
 
   tree res, vec = build_vector_from_val (type, op);
   if (is_gimple_val (vec))
@@ -9011,15 +9027,17 @@ gimple_build_vector_from_val (gimple_seq *seq, location_t loc, tree type,
     res = make_ssa_name (type);
   else
     res = create_tmp_reg (type);
+  gimple_seq seq = NULL;
   gimple *stmt = gimple_build_assign (res, vec);
   gimple_set_location (stmt, loc);
-  gimple_seq_add_stmt_without_update (seq, stmt);
+  gimple_seq_add_stmt_without_update (&seq, stmt);
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build a vector from BUILDER, handling the case in which some elements
-   are non-constant.  Return a gimple value for the result, appending any
-   new instructions to SEQ.
+   are non-constant.  Return a gimple value for the result, inserting
+   any new instructions to GSI honoring BEFORE and UPDATE.
 
    BUILDER must not have a stepped encoding on entry.  This is because
    the function is not geared up to handle the arithmetic that would
@@ -9027,14 +9045,16 @@ gimple_build_vector_from_val (gimple_seq *seq, location_t loc, tree type,
    is known to be constant should use BUILDER->build () directly.  */
 
 tree
-gimple_build_vector (gimple_seq *seq, location_t loc,
-		     tree_vector_builder *builder)
+gimple_build_vector (gimple_stmt_iterator *gsi,
+		     bool before, gsi_iterator_update update,
+		     location_t loc, tree_vector_builder *builder)
 {
   gcc_assert (builder->nelts_per_pattern () <= 2);
   unsigned int encoded_nelts = builder->encoded_nelts ();
   for (unsigned int i = 0; i < encoded_nelts; ++i)
     if (!CONSTANT_CLASS_P ((*builder)[i]))
       {
+	gimple_seq seq = NULL;
 	tree type = builder->type ();
 	unsigned int nelts = TYPE_VECTOR_SUBPARTS (type).to_constant ();
 	vec<constructor_elt, va_gc> *v;
@@ -9049,7 +9069,8 @@ gimple_build_vector (gimple_seq *seq, location_t loc,
 	  res = create_tmp_reg (type);
 	gimple *stmt = gimple_build_assign (res, build_constructor (type, v));
 	gimple_set_location (stmt, loc);
-	gimple_seq_add_stmt_without_update (seq, stmt);
+	gimple_seq_add_stmt_without_update (&seq, stmt);
+	gimple_build_insert_seq (gsi, before, update, seq);
 	return res;
       }
   return builder->build ();
@@ -9061,18 +9082,21 @@ gimple_build_vector (gimple_seq *seq, location_t loc,
    Return the tree node representing this size, it is of TREE_TYPE TYPE.  */
 
 tree
-gimple_build_round_up (gimple_seq *seq, location_t loc, tree type,
+gimple_build_round_up (gimple_stmt_iterator *gsi,
+		       bool before, gsi_iterator_update update,
+		       location_t loc, tree type,
 		       tree old_size, unsigned HOST_WIDE_INT align)
 {
   unsigned HOST_WIDE_INT tg_mask = align - 1;
   /* tree new_size = (old_size + tg_mask) & ~tg_mask;  */
   gcc_assert (INTEGRAL_TYPE_P (type));
   tree tree_mask = build_int_cst (type, tg_mask);
-  tree oversize = gimple_build (seq, loc, PLUS_EXPR, type, old_size,
-				tree_mask);
+  tree oversize = gimple_build (gsi, before, update,
+				loc, PLUS_EXPR, type, old_size, tree_mask);
 
   tree mask = build_int_cst (type, -align);
-  return gimple_build (seq, loc, BIT_AND_EXPR, type, oversize, mask);
+  return gimple_build (gsi, before, update,
+		       loc, BIT_AND_EXPR, type, oversize, mask);
 }
 
 /* Return true if the result of assignment STMT is known to be non-negative.
diff --git a/gcc/gimple-fold.h b/gcc/gimple-fold.h
index 520fde861e3..7d29ee9a9a4 100644
--- a/gcc/gimple-fold.h
+++ b/gcc/gimple-fold.h
@@ -98,59 +98,166 @@ gimple_build (gimple_seq *seq, enum tree_code code, tree type, Args ...ops)
 		       UNKNOWN_LOCATION, code, type, ops...);
 }
 
-extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree);
-extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree, tree);
-extern tree gimple_build (gimple_seq *, location_t, combined_fn,
-			  tree, tree, tree);
-extern tree gimple_build (gimple_seq *, location_t, combined_fn,
-			  tree, tree, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, combined_fn, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, combined_fn, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, combined_fn, tree, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, combined_fn, tree, tree, tree, tree);
+template<class ...Args>
+inline tree
+gimple_build (gimple_seq *seq, location_t loc,
+	      combined_fn fn, tree type, Args ...args)
+{
+  static_assert (sizeof...(args) < 4,
+		 "Number of arguments must be less than four");
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
+		       loc, fn, type, args...);
+}
 template<class ...Args>
 inline tree
 gimple_build (gimple_seq *seq, combined_fn fn, tree type, Args ...args)
 {
   static_assert (sizeof...(args) < 4,
 		 "Number of arguments must be less than four");
-  return gimple_build (seq, UNKNOWN_LOCATION, fn, type, args...);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
+		       UNKNOWN_LOCATION, fn, type, args...);
 }
 
-extern tree gimple_convert (gimple_seq *, location_t, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, code_helper, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, code_helper, tree, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, code_helper, tree, tree, tree, tree);
+
+template<class ...Args>
+inline tree
+gimple_build (gimple_seq *seq, location_t loc,
+	      code_helper code, tree type, Args ...ops)
+{
+  static_assert (sizeof...(ops) < 4,
+		 "Number of operands must be less than four");
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
+		       loc, code, type, ops...);
+}
+template<class ...Args>
+inline tree
+gimple_build (gimple_seq *seq,
+	      code_helper code, tree type, Args ...ops)
+{
+  static_assert (sizeof...(ops) < 4,
+		 "Number of operands must be less than four");
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
+		       UNKNOWN_LOCATION, code, type, ops...);
+}
+
+extern tree gimple_convert (gimple_stmt_iterator *, bool,
+			    enum gsi_iterator_update,
+			    location_t, tree, tree);
+inline tree
+gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
+{
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING, loc, type, op);
+}
 inline tree
 gimple_convert (gimple_seq *seq, tree type, tree op)
 {
-  return gimple_convert (seq, UNKNOWN_LOCATION, type, op);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING,
+			 UNKNOWN_LOCATION, type, op);
 }
 
-extern tree gimple_convert_to_ptrofftype (gimple_seq *, location_t, tree);
+extern tree gimple_convert_to_ptrofftype (gimple_stmt_iterator *, bool,
+					  enum gsi_iterator_update,
+					  location_t, tree);
+inline tree
+gimple_convert_to_ptrofftype (gimple_seq *seq, location_t loc, tree op)
+{
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_convert_to_ptrofftype (&gsi, false, GSI_CONTINUE_LINKING,
+				       loc, op);
+}
 inline tree
 gimple_convert_to_ptrofftype (gimple_seq *seq, tree op)
 {
-  return gimple_convert_to_ptrofftype (seq, UNKNOWN_LOCATION, op);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_convert_to_ptrofftype (&gsi, false, GSI_CONTINUE_LINKING,
+				       UNKNOWN_LOCATION, op);
 }
 
-extern tree gimple_build_vector_from_val (gimple_seq *, location_t, tree,
-					  tree);
+extern tree gimple_build_vector_from_val (gimple_stmt_iterator *, bool,
+					  enum gsi_iterator_update,
+					  location_t, tree, tree);
+inline tree
+gimple_build_vector_from_val (gimple_seq *seq, location_t loc,
+			      tree type, tree op)
+{
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_vector_from_val (&gsi, false, GSI_CONTINUE_LINKING,
+				       loc, type, op);
+}
 inline tree
 gimple_build_vector_from_val (gimple_seq *seq, tree type, tree op)
 {
-  return gimple_build_vector_from_val (seq, UNKNOWN_LOCATION, type, op);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_vector_from_val (&gsi, false, GSI_CONTINUE_LINKING,
+				       UNKNOWN_LOCATION, type, op);
 }
 
 class tree_vector_builder;
-extern tree gimple_build_vector (gimple_seq *, location_t,
-				 tree_vector_builder *);
+extern tree gimple_build_vector (gimple_stmt_iterator *, bool,
+				 enum gsi_iterator_update,
+				 location_t, tree_vector_builder *);
+inline tree
+gimple_build_vector (gimple_seq *seq, location_t loc,
+		     tree_vector_builder *builder)
+{
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
+			      loc, builder);
+}
 inline tree
 gimple_build_vector (gimple_seq *seq, tree_vector_builder *builder)
 {
-  return gimple_build_vector (seq, UNKNOWN_LOCATION, builder);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
+			      UNKNOWN_LOCATION, builder);
 }
 
-extern tree gimple_build_round_up (gimple_seq *, location_t, tree, tree,
+extern tree gimple_build_round_up (gimple_stmt_iterator *, bool,
+				   enum gsi_iterator_update,
+				   location_t, tree, tree,
 				   unsigned HOST_WIDE_INT);
 inline tree
+gimple_build_round_up (gimple_seq *seq, location_t loc,
+		       tree type, tree old_size, unsigned HOST_WIDE_INT align)
+{
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_round_up (&gsi, false, GSI_CONTINUE_LINKING,
+				loc, type, old_size, align);
+}
+inline tree
 gimple_build_round_up (gimple_seq *seq, tree type, tree old_size,
 		       unsigned HOST_WIDE_INT align)
 {
-  return gimple_build_round_up (seq, UNKNOWN_LOCATION, type, old_size, align);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_round_up (&gsi, false, GSI_CONTINUE_LINKING,
+				UNKNOWN_LOCATION, type, old_size, align);
 }
 
 extern bool gimple_stmt_nonnegative_warnv_p (gimple *, bool *, int = 0);
diff --git a/gcc/gimple-match.h b/gcc/gimple-match.h
index e96c31ed09f..d03789b6902 100644
--- a/gcc/gimple-match.h
+++ b/gcc/gimple-match.h
@@ -335,30 +335,4 @@ bool directly_supported_p (code_helper, tree, optab_subtype = optab_default);
 
 internal_fn get_conditional_internal_fn (code_helper, tree);
 
-extern tree gimple_build (gimple_seq *, location_t,
-			  code_helper, tree, tree);
-inline tree
-gimple_build (gimple_seq *seq, code_helper code, tree type, tree op0)
-{
-  return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0);
-}
-
-extern tree gimple_build (gimple_seq *, location_t,
-			  code_helper, tree, tree, tree);
-inline tree
-gimple_build (gimple_seq *seq, code_helper code, tree type, tree op0,
-	      tree op1)
-{
-  return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1);
-}
-
-extern tree gimple_build (gimple_seq *, location_t,
-			  code_helper, tree, tree, tree, tree);
-inline tree
-gimple_build (gimple_seq *seq, code_helper code, tree type, tree op0,
-	      tree op1, tree op2)
-{
-  return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1, op2);
-}
-
 #endif  /* GCC_GIMPLE_MATCH_H */
