fold-const.c (fold): For ((a * C1) / C3) or (((a * C1) + C2) / C3) optimizations...

* fold-const.c (fold): For ((a * C1) / C3) or (((a * C1) + C2) / C3)
        optimizations, look inside dividend to determine if the expression
        can be simplified by using EXACT_DIV_EXPR.

From-SVN: r16216
This commit is contained in:
Toon Moene 1997-10-28 20:02:23 +01:00 committed by Jeff Law
parent ede1993290
commit 750e83485a
2 changed files with 37 additions and 0 deletions

View File

@ -1,3 +1,9 @@
Tue Oct 28 11:58:40 1997 Toon Moene <toon@moene.indiv.nluug.nl>
* fold-const.c (fold): For ((a * C1) / C3) or (((a * C1) + C2) / C3)
optimizations, look inside dividend to determine if the expression
can be simplified by using EXACT_DIV_EXPR.
Tue Oct 28 10:19:01 1997 Jason Merrill <jason@yorick.cygnus.com>
From Brendan:

View File

@ -4655,6 +4655,37 @@ fold (expr)
STRIP_NOPS (xarg0);
/* Look inside the dividend and simplify using EXACT_DIV_EXPR
if possible. */
if (TREE_CODE (xarg0) == MULT_EXPR
&& multiple_of_p (type, TREE_OPERAND (xarg0, 0), arg1))
{
tree t;
t = fold (build (MULT_EXPR, type,
fold (build (EXACT_DIV_EXPR, type,
TREE_OPERAND (xarg0, 0), arg1)),
TREE_OPERAND (xarg0, 1)));
if (have_save_expr)
t = save_expr (t);
return t;
}
if (TREE_CODE (xarg0) == MULT_EXPR
&& multiple_of_p (type, TREE_OPERAND (xarg0, 1), arg1))
{
tree t;
t = fold (build (MULT_EXPR, type,
fold (build (EXACT_DIV_EXPR, type,
TREE_OPERAND (xarg0, 1), arg1)),
TREE_OPERAND (xarg0, 0)));
if (have_save_expr)
t = save_expr (t);
return t;
}
if (TREE_CODE (xarg0) == PLUS_EXPR
&& TREE_CODE (TREE_OPERAND (xarg0, 1)) == INTEGER_CST)
c2 = TREE_OPERAND (xarg0, 1), xarg0 = TREE_OPERAND (xarg0, 0);