fold-const.c (fold, [...]): Optimize 0 % X.

* fold-const.c (fold, case CEIL_MOD_EXPR): Optimize 0 % X.
        (case FLOOR_MOD_EXPR, ROUND_MOD_EXPR, TRUNC_MOD_EXPR): Similarly.

From-SVN: r94376
This commit is contained in:
Jeff Law 2005-01-28 09:35:46 -07:00 committed by Jeff Law
parent 1590d0d426
commit 139c978a44
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2005-01-28 Jeff Law <law@redhat.com>
* fold-const.c (fold, case CEIL_MOD_EXPR): Optimize 0 % X.
(case FLOOR_MOD_EXPR, ROUND_MOD_EXPR, TRUNC_MOD_EXPR): Similarly.
2005-01-28 Kazu Hirata <kazu@cs.umass.edu>
* cse.c (cse_reg_info_free_list, cse_reg_info_used_list,

View File

@ -7875,7 +7875,8 @@ fold (tree expr)
case FLOOR_MOD_EXPR:
case ROUND_MOD_EXPR:
case TRUNC_MOD_EXPR:
if (integer_onep (arg1))
/* 0 % X is always zero as is X % 1. */
if (integer_zerop (arg0) || integer_onep (arg1))
return omit_one_operand (type, integer_zero_node, arg0);
if (integer_zerop (arg1))
return t;