diff gcc/tree-scalar-evolution.c @ 63:b7f97abdc517 gcc-4.6-20100522

update gcc from gcc-4.5.0 to gcc-4.6
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 24 May 2010 12:47:05 +0900
parents 77e2b8dfacca
children f6334be47118
line wrap: on
line diff
--- a/gcc/tree-scalar-evolution.c	Fri Feb 12 23:41:23 2010 +0900
+++ b/gcc/tree-scalar-evolution.c	Mon May 24 12:47:05 2010 +0900
@@ -1,5 +1,5 @@
 /* Scalar evolution detector.
-   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Sebastian Pop <s.pop@laposte.net>
 
@@ -260,12 +260,10 @@
 #include "tm.h"
 #include "ggc.h"
 #include "tree.h"
-#include "real.h"
-
-/* These RTL headers are needed for basic-block.h.  */
-#include "rtl.h"
 #include "basic-block.h"
 #include "diagnostic.h"
+#include "tree-pretty-print.h"
+#include "gimple-pretty-print.h"
 #include "tree-flow.h"
 #include "tree-dump.h"
 #include "timevar.h"
@@ -1642,6 +1640,23 @@
   init_cond = analyze_initial_condition (loop_phi_node);
   res = analyze_evolution_in_loop (loop_phi_node, init_cond);
 
+  /* Verify we maintained the correct initial condition throughout
+     possible conversions in the SSA chain.  */
+  if (res != chrec_dont_know)
+    {
+      tree new_init = res;
+      if (CONVERT_EXPR_P (res)
+	  && TREE_CODE (TREE_OPERAND (res, 0)) == POLYNOMIAL_CHREC)
+	new_init = fold_convert (TREE_TYPE (res),
+				 CHREC_LEFT (TREE_OPERAND (res, 0)));
+      else if (TREE_CODE (res) == POLYNOMIAL_CHREC)
+	new_init = CHREC_LEFT (res);
+      STRIP_USELESS_TYPE_CONVERSION (new_init);
+      gcc_assert (TREE_CODE (new_init) != POLYNOMIAL_CHREC);
+      if (!operand_equal_p (init_cond, new_init, 0))
+	return chrec_dont_know;
+    }
+
   return res;
 }
 
@@ -3016,7 +3031,20 @@
     }
 }
 
-/* Cleans up the information cached by the scalar evolutions analysis.  */
+/* Cleans up the information cached by the scalar evolutions analysis
+   in the hash table.  */
+
+void
+scev_reset_htab (void)
+{
+  if (!scalar_evolution_info)
+    return;
+
+  htab_empty (scalar_evolution_info);
+}
+
+/* Cleans up the information cached by the scalar evolutions analysis
+   in the hash table and in the loop->nb_iterations.  */
 
 void
 scev_reset (void)
@@ -3024,10 +3052,11 @@
   loop_iterator li;
   struct loop *loop;
 
-  if (!scalar_evolution_info || !current_loops)
+  scev_reset_htab ();
+
+  if (!current_loops)
     return;
 
-  htab_empty (scalar_evolution_info);
   FOR_EACH_LOOP (li, loop, 0)
     {
       loop->nb_iterations = NULL_TREE;