[Bug tree-optimization/49218] Incorrect optimization of a 'for' loop creates an infinite loop

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon May 30 09:14:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49218

--- Comment #9 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-30 09:13:17 UTC ---
I'm going to test

@@ -3423,11 +3423,14 @@ adjust_range_with_scev (value_range_t *v
                                            loop->nb_iterations_upper_bound,
                                            double_int_one),
                                        unsigned_p, &overflow);
-      tem = double_int_to_tree (TREE_TYPE (init), dtmp);
       /* If the multiplication overflowed we can't do a meaningful
-        adjustment.  */
-      if (!overflow && double_int_equal_p (dtmp, tree_to_double_int (tem)))
+        adjustment.  Likewise if the unsigned result doesn't fit in the type
+        of the induction variable.  */
+      if (!overflow
+         && double_int_fits_to_tree_p (TREE_TYPE (init), dtmp)
+         && (unsigned_p || dtmp.high > 0))
        {
+         tem = double_int_to_tree (TREE_TYPE (init), dtmp);
          extract_range_from_binary_expr (&maxvr, PLUS_EXPR,
                                          TREE_TYPE (init), init, tem);
          /* Likewise if the addition did.  */



More information about the Gcc-bugs mailing list