loop.h (struct induction): Add no_const_addval.

* loop.h (struct induction): Add no_const_addval.
        * loop.c (the_movables, reg_address_cost): New variables.
        (init_loop): Init reg_address_cost.
        (loop_optimize): Call end_alias_analysis.
        (scan_loop): Init the_movables.
        (record_giv): Init induction->no_const_addval.
        (basic_induction_var) [PLUS]: Use rtx_equal_p instead of ==.
        [REG]: Rearrange loop search test to catch more cases.
        (general_induction_var): Return success not benefit; take an extra
        argument for that.  Change all callers.
        (simplify_giv_expr) [PLUS]: Always combine invariants.  Use sge_plus.
        [MULT]: Use rtx_equal_p instead of ==.  Combine simple invariants.
        [default]: Search the_movables for additional combinations.
        (sge_plus_constant, sge_plus): New functions.
        (express_from_1): New function.
        (express_from): Always define.  Rewrite using express_from_1.
        (combine_givs_p): Handle more cases.  Ignore address cost.
        (cmp_combine_givs_stats): New function.
        (combine_givs_used_once, combine_givs_benefit_from): New functions.
        (combine_givs): Rewrite to do best-fit combination.
        * fold-const.c (operand_equal_p): Handle RTL_EXPR.
        (fold): Do a complete (A*C)+(B*C) association check.

From-SVN: r21263
This commit is contained in:
Richard Henderson 1998-07-17 07:46:06 -07:00 committed by Richard Henderson
parent d4c011bca5
commit 45f97e2e08
4 changed files with 669 additions and 201 deletions

View file

@ -1,3 +1,29 @@
Fri Jul 17 14:18:14 1998 Richard Henderson <rth@cygnus.com>
* loop.h (struct induction): Add no_const_addval.
* loop.c (the_movables, reg_address_cost): New variables.
(init_loop): Init reg_address_cost.
(loop_optimize): Call end_alias_analysis.
(scan_loop): Init the_movables.
(record_giv): Init induction->no_const_addval.
(basic_induction_var) [PLUS]: Use rtx_equal_p instead of ==.
[REG]: Rearrange loop search test to catch more cases.
(general_induction_var): Return success not benefit; take an extra
argument for that. Change all callers.
(simplify_giv_expr) [PLUS]: Always combine invariants. Use sge_plus.
[MULT]: Use rtx_equal_p instead of ==. Combine simple invariants.
[default]: Search the_movables for additional combinations.
(sge_plus_constant, sge_plus): New functions.
(express_from_1): New function.
(express_from): Always define. Rewrite using express_from_1.
(combine_givs_p): Handle more cases. Ignore address cost.
(cmp_combine_givs_stats): New function.
(combine_givs_used_once, combine_givs_benefit_from): New functions.
(combine_givs): Rewrite to do best-fit combination.
* fold-const.c (operand_equal_p): Handle RTL_EXPR.
(fold): Do a complete (A*C)+(B*C) association check.
Fri Jul 17 11:21:55 1998 Jim Wilson <wilson@cygnus.com>
* function.c (fixup_var_refs_insns): Handle CLOBBER of a CONCAT.

View file

@ -1928,6 +1928,11 @@ operand_equal_p (arg0, arg1, only_const)
default:
return 0;
}
case 'e':
if (TREE_CODE (arg0) == RTL_EXPR)
return rtx_equal_p (RTL_EXPR_RTL (arg0), RTL_EXPR_RTL (arg1));
return 0;
default:
return 0;
@ -4413,18 +4418,36 @@ fold (expr)
goto bit_ior;
}
/* (A * C) + (B * C) -> (A+B) * C. Since we are most concerned
about the case where C is a constant, just try one of the
four possibilities. */
if (TREE_CODE (arg0) == MULT_EXPR && TREE_CODE (arg1) == MULT_EXPR)
{
tree arg00, arg01, arg10, arg11;
tree alt0, alt1, same;
if (TREE_CODE (arg0) == MULT_EXPR && TREE_CODE (arg1) == MULT_EXPR
&& operand_equal_p (TREE_OPERAND (arg0, 1),
TREE_OPERAND (arg1, 1), 0))
return fold (build (MULT_EXPR, type,
fold (build (PLUS_EXPR, type,
TREE_OPERAND (arg0, 0),
TREE_OPERAND (arg1, 0))),
TREE_OPERAND (arg0, 1)));
/* (A * C) + (B * C) -> (A+B) * C.
We are most concerned about the case where C is a constant,
but other combinations show up during loop reduction. Since
it is not difficult, try all four possibilities. */
arg00 = TREE_OPERAND (arg0, 0);
arg01 = TREE_OPERAND (arg0, 1);
arg10 = TREE_OPERAND (arg1, 0);
arg11 = TREE_OPERAND (arg1, 1);
same = NULL_TREE;
if (operand_equal_p (arg01, arg11, 0))
same = arg01, alt0 = arg00, alt1 = arg10;
else if (operand_equal_p (arg00, arg10, 0))
same = arg00, alt0 = arg01, alt1 = arg11;
else if (operand_equal_p (arg00, arg11, 0))
same = arg00, alt0 = arg01, alt1 = arg10;
else if (operand_equal_p (arg01, arg10, 0))
same = arg01, alt0 = arg00, alt1 = arg11;
if (same)
return fold (build (MULT_EXPR, type,
fold (build (PLUS_EXPR, type, alt0, alt1)),
same));
}
}
/* In IEEE floating point, x+0 may not equal x. */
else if ((TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT

File diff suppressed because it is too large Load diff

View file

@ -95,6 +95,7 @@ struct induction
unsigned unrolled : 1; /* 1 if new register has been allocated and
initialized in unrolled loop. */
unsigned shared : 1;
unsigned no_const_addval : 1; /* 1 if add_val does not contain a const. */
int lifetime; /* Length of life of this giv */
int times_used; /* # times this giv is used. */
rtx derive_adjustment; /* If nonzero, is an adjustment to be