diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f187e61d11fa8293cc805a1e27a6c898ed2ad369..8a742f9253be8d8ed32929459ecb8872e7436d4c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2007-12-14  Richard Guenther  <rguenther@suse.de>
+
+	PR middle-end/34462
+	* tree-ssa-operands.h (create_ssa_artificial_load_stmt): Add
+	parameter to say whether to unlink immediate uses.
+	* tree-ssa-operands.c (create_ssa_artificial_load_stmt): Do not
+	mark the artificial stmt as modified.  Unlink immediate uses
+	only if requested.
+	* tree-ssa-dom.c (record_equivalences_from_stmt): Update caller.
+	* tree-ssa-pre.c (insert_fake_stores): Likewise.
+
 2007-12-13  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
 	PR middle-end/33088
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 35c1880463ed30775cc0bb37ef33a85dea9958d8..56448f4202c8feba98b7e4dd49db36da2b20b44b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-12-14  Richard Guenther  <rguenther@suse.de>
+
+	PR middle-end/34462
+	* gcc.c-torture/compile/20071214-1.c: New testcase.
+
 2007-12-14  Uros Bizjak  <ubizjak@gmail.com>
 
 	* gcc.target/i386/sse-14.c (test_1, test_2, test_2x, test_4): New
diff --git a/gcc/testsuite/gcc.c-torture/compile/20071214-1.c b/gcc/testsuite/gcc.c-torture/compile/20071214-1.c
new file mode 100644
index 0000000000000000000000000000000000000000..f30af930630f315fc5b39124b83a343593b6dae3
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20071214-1.c
@@ -0,0 +1,15 @@
+typedef __builtin_va_list va_list;
+void gftp_config_parse_args (int numargs, char **first, ...)
+{
+  char **dest = first;
+  va_list argp;
+  __builtin_va_start (argp, first);
+  while (numargs-- > 0)
+    {
+      *dest = __builtin_malloc (1);
+      dest = __builtin_va_arg(argp, char **);
+      *dest = ((void *)0);
+    }
+  __builtin_va_end(argp);
+}
+
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 7bed1c292d85d37f1bdcdb5c04fafb788c4dc0cf..bc9809edfc2981386bf70df38234122793bf94d3 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1618,7 +1618,7 @@ record_equivalences_from_stmt (tree stmt, int may_optimize_p, stmt_ann_t ann)
 	  /* Build a new statement with the RHS and LHS exchanged.  */
 	  new_stmt = build_gimple_modify_stmt (rhs, lhs);
 
-	  create_ssa_artificial_load_stmt (new_stmt, stmt);
+	  create_ssa_artificial_load_stmt (new_stmt, stmt, true);
 
 	  /* Finally enter the statement into the available expression
 	     table.  */
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index fb611664c0937a820ae35e972ca1b13e40c4a0fb..72f44338b2d09463bc6c847214641880cf5bb5ef 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -2647,17 +2647,23 @@ copy_virtual_operands (tree dest, tree src)
    create an artificial stmt which looks like a load from the store, this can
    be used to eliminate redundant loads.  OLD_OPS are the operands from the 
    store stmt, and NEW_STMT is the new load which represents a load of the
-   values stored.  */
+   values stored.  If DELINK_IMM_USES_P is specified, the immediate
+   uses of this stmt will be de-linked.  */
 
 void
-create_ssa_artificial_load_stmt (tree new_stmt, tree old_stmt)
+create_ssa_artificial_load_stmt (tree new_stmt, tree old_stmt,
+				 bool delink_imm_uses_p)
 {
   tree op;
   ssa_op_iter iter;
   use_operand_p use_p;
   unsigned i;
+  stmt_ann_t ann;
 
-  get_stmt_ann (new_stmt);
+  /* Create the stmt annotation but make sure to not mark the stmt
+     as modified as we will build operands ourselves.  */
+  ann = get_stmt_ann (new_stmt);
+  ann->modified = 0;
 
   /* Process NEW_STMT looking for operands.  */
   start_ssa_stmt_operands ();
@@ -2687,8 +2693,9 @@ create_ssa_artificial_load_stmt (tree new_stmt, tree old_stmt)
   finalize_ssa_stmt_operands (new_stmt);
 
   /* All uses in this fake stmt must not be in the immediate use lists.  */
-  FOR_EACH_SSA_USE_OPERAND (use_p, new_stmt, iter, SSA_OP_ALL_USES)
-    delink_imm_use (use_p);
+  if (delink_imm_uses_p)
+    FOR_EACH_SSA_USE_OPERAND (use_p, new_stmt, iter, SSA_OP_ALL_USES)
+      delink_imm_use (use_p);
 }
 
 
diff --git a/gcc/tree-ssa-operands.h b/gcc/tree-ssa-operands.h
index 4dc344e93072f9d7218fbdd444b5361bbda69c63..f48245f7da6f9ac53bd7e59193607d86beb7e425 100644
--- a/gcc/tree-ssa-operands.h
+++ b/gcc/tree-ssa-operands.h
@@ -210,7 +210,7 @@ extern void free_stmt_operands (tree);
 extern bool verify_imm_links (FILE *f, tree var);
 
 extern void copy_virtual_operands (tree, tree);
-extern void create_ssa_artificial_load_stmt (tree, tree);
+extern void create_ssa_artificial_load_stmt (tree, tree, bool);
 
 extern void dump_immediate_uses (FILE *file);
 extern void dump_immediate_uses_for (FILE *file, tree var);
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 69dbfb2b9a3beca9bd35bb36bb13295d68e5fc1e..6a06b2a80047f56545328b5a72178482f7348676 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3171,7 +3171,7 @@ insert_fake_stores (void)
 
 	      lhs = make_ssa_name (storetemp, new_tree);
 	      GIMPLE_STMT_OPERAND (new_tree, 0) = lhs;
-	      create_ssa_artificial_load_stmt (new_tree, stmt);
+	      create_ssa_artificial_load_stmt (new_tree, stmt, false);
 
 	      NECESSARY (new_tree) = 0;
 	      VEC_safe_push (tree, heap, inserted_exprs, new_tree);