From 2931700801f5ac2d996bc35927674e314629062c Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sat, 18 Dec 2004 11:03:49 -0800 Subject: [PATCH] fold-const.c (multiple_of_p): Handle BIT_AND_EXPR when BOTTOM is a power of two. * fold-const.c (multiple_of_p): Handle BIT_AND_EXPR when BOTTOM is a power of two. From-SVN: r92358 --- gcc/ChangeLog | 5 +++++ gcc/fold-const.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 77b5100..64935f6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2004-12-18 Richard Henderson + * fold-const.c (multiple_of_p): Handle BIT_AND_EXPR when + BOTTOM is a power of two. + +2004-12-18 Richard Henderson + * tree-nested.c (save_tmp_var): New. (struct walk_stmt_info): Add is_lhs. (walk_stmts) : Be more accurate with setting of diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 2fe0b7e..d249f75 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)); -- 2.7.4