re PR tree-optimization/19937 (Wrong loop exit (causes binutils to fail))
authorZdenek Dvorak <dvorakz@suse.cz>
Fri, 25 Feb 2005 12:07:11 +0000 (13:07 +0100)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Fri, 25 Feb 2005 12:07:11 +0000 (12:07 +0000)
PR tree-optimization/19937
* tree-ssa-loop-ivopts.c (rewrite_use_compare): Cast the final value
to the type of the induction variable.

From-SVN: r95535

gcc/ChangeLog
gcc/tree-ssa-loop-ivopts.c

index a41808c2e48a45db6731a389309758421f53a033..ef164be76618902bbe8f2e6cb4889364f40c8c5b 100644 (file)
@@ -1,3 +1,9 @@
+2005-02-25  Zdenek Dvorak  <dvorakz@suse.cz>
+
+       PR tree-optimization/19937
+       * tree-ssa-loop-ivopts.c (rewrite_use_compare): Cast the final value
+       to the type of the induction variable.
+
 2005-02-25  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        PR rtl-optimization/20117
index 8b069d058d7a4fe61b93451f1b278a1bf56b4dd9..b1636a7ffe998486e53125da37c06b2aa90a050d 100644 (file)
@@ -4878,15 +4878,17 @@ rewrite_use_compare (struct ivopts_data *data,
   
   if (may_eliminate_iv (data, use, cand, &compare, &bound))
     {
+      tree var = var_at_stmt (data->current_loop, cand, use->stmt);
+      tree var_type = TREE_TYPE (var);
+
+      bound = fold_convert (var_type, bound);
       op = force_gimple_operand (unshare_expr (bound), &stmts,
                                 true, NULL_TREE);
 
       if (stmts)
        bsi_insert_before (&bsi, stmts, BSI_SAME_STMT);
 
-      *use->op_p = build2 (compare, boolean_type_node,
-                         var_at_stmt (data->current_loop,
-                                      cand, use->stmt), op);
+      *use->op_p = build2 (compare, boolean_type_node, var, op);
       modify_stmt (use->stmt);
       return;
     }