diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6c05926a8c7e9c38a5ab337926f63e06f7b40248..fb72e0a2f6ef1e5bc48e2d8b854556111da47177 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-22  Zdenek Dvorak <dvorakz@suse.cz>
+
+	PR tree-optimization/29902
+	* tree-ssa-loop-manip.c (can_unroll_loop_p): Return false if
+	any involved ssa name appears in abnormal phi node.
+
 2006-11-21  Bob Wilson  <bob.wilson@acm.org>
 
 	* config/xtensa/xtensa.c (xtensa_char_to_class): Delete.
@@ -19,7 +25,7 @@
 2006-11-21  Janis Johnson  <janis187@us.ibm.com>
 
 	* config/dfp-bits.c (DFP_TO_INT): Remove code to saturate result
- 	of conversion that doesn't fit.
+	of conversion that doesn't fit.
 
 	* config/dfp-bit.h (CONTEXT_TRAPS, CONTEXT_ERRORS, DFP_RAISE): Delete.
 	* config/dfp-bit.c (dfp_unary_op, dfp_binary_op, dfp_compare_op,
@@ -29,7 +35,7 @@
 
 2006-11-21  Douglas Gregor <doug.gregor@gmail.com>
 
-        * c-common.h (enum rid): Add RID_STATIC_ASSERT.
+	* c-common.h (enum rid): Add RID_STATIC_ASSERT.
 
 2006-11-21  Richard Guenther  <rguenther@suse.de>
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f4e5182233b2b843289631c1d5f4f7822b4fa3f4..58ed09da58be03ccb8a5813500f641cfa9201242 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-11-22  Zdenek Dvorak <dvorakz@suse.cz>
+
+	PR tree-optimization/29902
+	* g++.dg/tree-ssa/pr29902.C: New test.
+
 2006-11-21 Paul Thomas  <pault@gcc.gnu.org>
 
 	PR fortran/29820
@@ -9,9 +14,9 @@
 
 2006-11-21  Douglas Gregor  <doug.gregor@gmail.com>
 
-        * g++.dg/cpp0x/static_assert1.C: New.
-        * g++.dg/cpp0x/static_assert2.C: New.
-        * g++.dg/cpp0x/static_assert3.C: New.
+	* g++.dg/cpp0x/static_assert1.C: New.
+	* g++.dg/cpp0x/static_assert2.C: New.
+	* g++.dg/cpp0x/static_assert3.C: New.
 
 2006-11-21  Richard Guenther  <rguenther@suse.de>
 
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr29902.C b/gcc/testsuite/g++.dg/tree-ssa/pr29902.C
new file mode 100644
index 0000000000000000000000000000000000000000..c81101d1a0a40abd24b532138735229e4be51cdc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr29902.C
@@ -0,0 +1,19 @@
+/* { dg-do compile { target i?86-*-* } } */
+/* { dg-options "-O1 -fprefetch-loop-arrays -march=athlon" } */
+
+int length1();
+int g(int);
+void f(int capacity_, char *old_storage)
+{
+  try {
+      length1();
+      int old_capacity = capacity_;
+      capacity_ *= 2;
+      g(capacity_);
+      for (int i = 1; i < old_capacity; i++)
+	old_storage[i] = old_storage[i - 1];
+  } catch (...) {
+      for (int i = 1; i < capacity_; i++){old_storage[i] = 0;}
+  }
+}
+
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 68e0fa6fe492c166ce32351a6cd43acc365b0446..a23c787ccbefe2fd322f356c14013fac05d29785 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -625,7 +625,16 @@ can_unroll_loop_p (struct loop *loop, unsigned factor,
     return false;
 
   if (!number_of_iterations_exit (loop, exit, niter, false)
-      || niter->cmp == ERROR_MARK)
+      || niter->cmp == ERROR_MARK
+      /* Scalar evolutions analysis might have copy propagated
+	 the abnormal ssa names into these expressions, hence
+	 emiting the computations based on them during loop
+	 unrolling might create overlapping life ranges for
+	 them, and failures in out-of-ssa.  */
+      || contains_abnormal_ssa_name_p (niter->may_be_zero)
+      || contains_abnormal_ssa_name_p (niter->control.base)
+      || contains_abnormal_ssa_name_p (niter->control.step)
+      || contains_abnormal_ssa_name_p (niter->bound))
     return false;
 
   /* And of course, we must be able to duplicate the loop.  */