diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-30 21:33:32 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-30 21:33:32 +0000 |
commit | 9ae13cc6f4a8b8e94ee762813b673191a94280b1 (patch) | |
tree | dd32c83a5ab688b1765c9c952a826e5e04b594de /gcc/loop.c | |
parent | cb59f96973826a295b4f864bcda38b240ba33e44 (diff) | |
download | gcc-9ae13cc6f4a8b8e94ee762813b673191a94280b1.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54075 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/loop.c')
-rw-r--r-- | gcc/loop.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/gcc/loop.c b/gcc/loop.c index 8581af2746e..20c5f1dab0a 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -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; } |