diff options
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 77b5100c7d9..64935f63fb6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2004-12-18 Richard Henderson <rth@redhat.com> + * fold-const.c (multiple_of_p): Handle BIT_AND_EXPR when + BOTTOM is a power of two. + +2004-12-18 Richard Henderson <rth@redhat.com> + * tree-nested.c (save_tmp_var): New. (struct walk_stmt_info): Add is_lhs. (walk_stmts) <MODIFY_EXPR>: Be more accurate with setting of diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 2fe0b7e7d2b..d249f753312 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9541,6 +9541,13 @@ multiple_of_p (tree type, tree top, tree bottom) switch (TREE_CODE (top)) { + case BIT_AND_EXPR: + /* Bitwise and provides a power of two multiple. If the mask is + a multiple of BOTTOM then TOP is a multiple of BOTTOM. */ + if (!integer_pow2p (bottom)) + return 0; + /* FALLTHRU */ + case MULT_EXPR: return (multiple_of_p (type, TREE_OPERAND (top, 0), bottom) || multiple_of_p (type, TREE_OPERAND (top, 1), bottom)); |