+ /* If we have ((a / C1) / C2) where both division are the same type, tr
+ to simplify. First see if C1 * C2 overflows or not. */
+ if (TREE_CODE (arg0) == code && TREE_CODE (arg1) == INTEGER_CST
+ && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST)
+ {
+ tem = const_binop (MULT_EXPR, TREE_OPERAND (arg0, 1), arg1, 0);
+
+ /* If it overflows, the result is +/- 1 or zero, depending on
+ the signs of the two constants and the division operation. */
+ if (TREE_OVERFLOW (tem))
+ {
+ switch (code)
+ {
+ case EXACT_DIV_EXPR:
+ case TRUNC_DIV_EXPR:
+ tem = integer_zero_node;
+ break;
+ case FLOOR_DIV_EXPR:
+ /* -1 if signs disagree, else 0. */
+ tem = (((tree_int_cst_sgn (TREE_OPERAND (arg0, 1)) < 0)
+ != (tree_int_cst_sgn (arg1) < 0))
+ ? build_int_2 (-1, -1) : integer_zero_node);
+ break;
+ case CEIL_DIV_EXPR:
+ /* 1 if signs agree, else 0. */
+ tem = (((tree_int_cst_sgn (TREE_OPERAND (arg0, 1)) < 0)
+ == (tree_int_cst_sgn (arg1) < 0))
+ ? integer_one_node : integer_zero_node);
+ break;
+ }
+
+ return omit_one_operand (type, tem, TREE_OPERAND (arg0, 0));
+ }
+ else
+ /* If no overflow, divide by C1*C2. */
+ return fold (build (code, type, TREE_OPERAND (arg0, 0), tem));
+ }
+