diff options
author | Eric Botcazou <ebotcazou@multimania.com> | 2002-05-30 21:33:32 +0000 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2002-05-30 14:33:32 -0700 |
commit | ce60bf25b22ac87577c2e4efdc5a1bdacaa05151 (patch) | |
tree | dd32c83a5ab688b1765c9c952a826e5e04b594de /gcc/loop.c | |
parent | d18b1ed89ece9698c8e3d0a90534bbf9fe103951 (diff) | |
download | gcc-ce60bf25b22ac87577c2e4efdc5a1bdacaa05151.zip gcc-ce60bf25b22ac87577c2e4efdc5a1bdacaa05151.tar.gz gcc-ce60bf25b22ac87577c2e4efdc5a1bdacaa05151.tar.bz2 |
expmed.c (const_mult_add_overflow_p): New.
* expmed.c (const_mult_add_overflow_p): New.
* expr.h: Declare it.
* loop.c (maybe_eliminate_biv_1) [COMPARE]: Use it.
Don't eliminate the biv if the giv has a constant multiplier and
the rhs argument of the comparison does satisfy the predicate.
Use expand_mult_add to compute the replacement constant.
From-SVN: r54075
Diffstat (limited to 'gcc/loop.c')
-rw-r--r-- | gcc/loop.c | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -8863,6 +8863,22 @@ maybe_eliminate_biv_1 (loop, x, insn, bl, eliminate_p, where_bb, where_insn) if (! biv_elimination_giv_has_0_offset (bl->biv, v, insn)) continue; + /* Don't eliminate if the linear combination that makes up + the giv overflows when it is applied to ARG. */ + if (GET_CODE (arg) == CONST_INT) + { + rtx add_val; + + if (GET_CODE (v->add_val) == CONST_INT) + add_val = v->add_val; + else + add_val = const0_rtx; + + if (const_mult_add_overflow_p (arg, v->mult_val, + add_val, mode, 1)) + continue; + } + if (! eliminate_p) return 1; @@ -8873,13 +8889,10 @@ maybe_eliminate_biv_1 (loop, x, insn, bl, eliminate_p, where_bb, where_insn) the derived constant can be directly placed in the COMPARE, do so. */ if (GET_CODE (arg) == CONST_INT - && GET_CODE (v->mult_val) == CONST_INT && GET_CODE (v->add_val) == CONST_INT) { - validate_change (insn, &XEXP (x, arg_operand), - GEN_INT (INTVAL (arg) - * INTVAL (v->mult_val) - + INTVAL (v->add_val)), 1); + tem = expand_mult_add (arg, NULL_RTX, v->mult_val, + v->add_val, mode, 1); } else { @@ -8888,8 +8901,10 @@ maybe_eliminate_biv_1 (loop, x, insn, bl, eliminate_p, where_bb, where_insn) loop_iv_add_mult_emit_before (loop, arg, v->mult_val, v->add_val, tem, where_bb, where_insn); - validate_change (insn, &XEXP (x, arg_operand), tem, 1); } + + validate_change (insn, &XEXP (x, arg_operand), tem, 1); + if (apply_change_group ()) return 1; } |