+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:
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);