aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorToon Moene <toon@moene.indiv.nluug.nl>1997-10-28 20:02:23 +0100
committerJeff Law <law@gcc.gnu.org>1997-10-28 12:02:23 -0700
commit750e83485a2a2e2a6b09368000961827d0f7b8a8 (patch)
treeb9bcdf0a69d79c64253d4f4fd74b9910a63c10c0 /gcc
parentede199329090ba13ce5679dbf99732f2727f8ee9 (diff)
downloadgcc-750e83485a2a2e2a6b09368000961827d0f7b8a8.zip
gcc-750e83485a2a2e2a6b09368000961827d0f7b8a8.tar.gz
gcc-750e83485a2a2e2a6b09368000961827d0f7b8a8.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/fold-const.c31
2 files changed, 37 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9d7055e..0b3f40f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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:
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 1e823fb..da18997 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -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);