(fold, case MULT_EXPR): Simplify MULT_EXPR of an EXACT_DIV_EXPR with
authorRichard Kenner <kenner@gcc.gnu.org>
Wed, 9 Mar 1994 21:50:25 +0000 (16:50 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Wed, 9 Mar 1994 21:50:25 +0000 (16:50 -0500)
the same divisor as our multiplicand.

From-SVN: r6734

gcc/fold-const.c

index 600bbfa728ee85e6845b740ae491ddaee1a98ee3..304eac88f7ebbf384c0e4dd63ff69c5ee83af9d6 100644 (file)
@@ -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)))