aboutsummaryrefslogtreecommitdiff
path: root/gcc/loop.c
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@redhat.com>2004-07-27 07:27:12 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2004-07-27 07:27:12 +0000
commit45d09c02e544c4074aa4a69925c1fe547a0dd7a0 (patch)
tree3acb7007422c04dcb1bc209a9aeb6d560798c498 /gcc/loop.c
parentdbe9c577763c34327150e88314c3f8b633f4be99 (diff)
downloadgcc-45d09c02e544c4074aa4a69925c1fe547a0dd7a0.zip
gcc-45d09c02e544c4074aa4a69925c1fe547a0dd7a0.tar.gz
gcc-45d09c02e544c4074aa4a69925c1fe547a0dd7a0.tar.bz2
expr.h (canonicalize_condition, [...]): Add an int argument.
* expr.h (canonicalize_condition, get_condition): Add an int argument. * gcse.c (fis_get_condition): Reimplement using get_condition, leaving it to check whether the condition is still valid at the jump insn. * ifcvt.c (noce_get_condition): Likewise. (noce_get_alt_condition): Update call to canonicalize_condition. * loop-iv.c (simplify_using_initial_values): Update call to get_condition. Remove FIXME. (check_simple_exit): Update call to get_condition. * loop-unswitch.c (may_unswitch_on): Likewise. * loop.c (check_dbra_loop): Likewise. (canonicalize_condition, get_condition): Add an argument to say whether the condition must still be valid at INSN. (get_condition_for_loop): Update call to get_condition. Require that the condition be valid at INSN. * predict.c (estimate_probability): Update call to get_condition. Remove unused earliest parameter. (expected_value_to_br_prob): Update call to canonicalize_condition. From-SVN: r85218
Diffstat (limited to 'gcc/loop.c')
-rw-r--r--gcc/loop.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/gcc/loop.c b/gcc/loop.c
index a6353d7..c8a16e0 100644
--- a/gcc/loop.c
+++ b/gcc/loop.c
@@ -8001,7 +8001,7 @@ check_dbra_loop (struct loop *loop, int insn_count)
/* Try to compute whether the compare/branch at the loop end is one or
two instructions. */
- get_condition (jump, &first_compare, false);
+ get_condition (jump, &first_compare, false, true);
if (first_compare == jump)
compare_and_branch = 1;
else if (first_compare == prev_nonnote_insn (jump))
@@ -9195,11 +9195,14 @@ update_reg_last_use (rtx x, rtx insn)
If WANT_REG is nonzero, we wish the condition to be relative to that
register, if possible. Therefore, do not canonicalize the condition
further. If ALLOW_CC_MODE is nonzero, allow the condition returned
- to be a compare to a CC mode register. */
+ to be a compare to a CC mode register.
+
+ If VALID_AT_INSN_P, the condition must be valid at both *EARLIEST
+ and at INSN. */
rtx
canonicalize_condition (rtx insn, rtx cond, int reverse, rtx *earliest,
- rtx want_reg, int allow_cc_mode)
+ rtx want_reg, int allow_cc_mode, int valid_at_insn_p)
{
enum rtx_code code;
rtx prev = insn;
@@ -9357,6 +9360,11 @@ canonicalize_condition (rtx insn, rtx cond, int reverse, rtx *earliest,
if (x)
{
+ /* If the caller is expecting the condition to be valid at INSN,
+ make sure X doesn't change before INSN. */
+ if (valid_at_insn_p)
+ if (modified_in_p (x, prev) || modified_between_p (x, prev, insn))
+ break;
if (COMPARISON_P (x))
code = GET_CODE (x);
if (reverse_code)
@@ -9443,13 +9451,16 @@ canonicalize_condition (rtx insn, rtx cond, int reverse, rtx *earliest,
If EARLIEST is nonzero, it is a pointer to a place where the earliest
insn used in locating the condition was found. If a replacement test
of the condition is desired, it should be placed in front of that
- insn and we will be sure that the inputs are still valid.
+ insn and we will be sure that the inputs are still valid. If EARLIEST
+ is null, the returned condition will be valid at INSN.
If ALLOW_CC_MODE is nonzero, allow the condition returned to be a
- compare CC mode register. */
+ compare CC mode register.
+
+ VALID_AT_INSN_P is the same as for canonicalize_condition. */
rtx
-get_condition (rtx jump, rtx *earliest, int allow_cc_mode)
+get_condition (rtx jump, rtx *earliest, int allow_cc_mode, int valid_at_insn_p)
{
rtx cond;
int reverse;
@@ -9470,7 +9481,7 @@ get_condition (rtx jump, rtx *earliest, int allow_cc_mode)
&& XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (jump);
return canonicalize_condition (jump, cond, reverse, earliest, NULL_RTX,
- allow_cc_mode);
+ allow_cc_mode, valid_at_insn_p);
}
/* Similar to above routine, except that we also put an invariant last
@@ -9479,7 +9490,7 @@ get_condition (rtx jump, rtx *earliest, int allow_cc_mode)
rtx
get_condition_for_loop (const struct loop *loop, rtx x)
{
- rtx comparison = get_condition (x, (rtx*) 0, false);
+ rtx comparison = get_condition (x, (rtx*) 0, false, true);
if (comparison == 0
|| ! loop_invariant_p (loop, XEXP (comparison, 0))