aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1994-03-09 16:50:25 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1994-03-09 16:50:25 -0500
commitb9b5c1b3764818c3446edc4668c60bf7bed59c87 (patch)
tree85c694bdc521a1a625579a3e2acb915b1759fb0d /gcc
parent6946afd3a556e0681ea8f381d2492c26b98a8a39 (diff)
downloadgcc-b9b5c1b3764818c3446edc4668c60bf7bed59c87.zip
gcc-b9b5c1b3764818c3446edc4668c60bf7bed59c87.tar.gz
gcc-b9b5c1b3764818c3446edc4668c60bf7bed59c87.tar.bz2
(fold, case MULT_EXPR): Simplify MULT_EXPR of an EXACT_DIV_EXPR with
the same divisor as our multiplicand. From-SVN: r6734
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fold-const.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 600bbfa..304eac8 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3820,6 +3820,14 @@ fold (expr)
if (integer_onep (arg1))
return non_lvalue (convert (type, arg0));
+ /* ((A / C) * C) is A if the division is an
+ EXACT_DIV_EXPR. Since C is normally a constant,
+ just check for one of the four possibilities. */
+
+ if (TREE_CODE (arg0) == EXACT_DIV_EXPR
+ && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0))
+ return TREE_OPERAND (arg0, 0);
+
/* (a * (1 << b)) is (a << b) */
if (TREE_CODE (arg1) == LSHIFT_EXPR
&& integer_onep (TREE_OPERAND (arg1, 0)))