From 9e7376e5952775dca8267df699af56fb53e69739 Mon Sep 17 00:00:00 2001 From: Zdenek Dvorak Date: Fri, 25 Feb 2005 13:07:11 +0100 Subject: [PATCH] re PR tree-optimization/19937 (Wrong loop exit (causes binutils to fail)) 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 | 6 ++++++ gcc/tree-ssa-loop-ivopts.c | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a41808c..ef164be 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-02-25 Zdenek Dvorak + + 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 PR rtl-optimization/20117 diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 8b069d0..b1636a7 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -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; } -- 2.7.4