diff options
author | Roger Sayle <roger@eyesopen.com> | 2002-06-01 16:51:00 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2002-06-01 16:51:00 +0000 |
commit | 01c58f2670a5f7858b8762e06cab0a68b98a684f (patch) | |
tree | 1ca73084ca38923e70f162fc15f33747a48b65c7 /gcc/fold-const.c | |
parent | 91b1247259cffcd3eb65721d21349b1a9eccafe3 (diff) | |
download | gcc-01c58f2670a5f7858b8762e06cab0a68b98a684f.zip gcc-01c58f2670a5f7858b8762e06cab0a68b98a684f.tar.gz gcc-01c58f2670a5f7858b8762e06cab0a68b98a684f.tar.bz2 |
fold-const.c (fold_truthop): Transform "a || b" into "(a|b) != 0" and "!p && !q" into "(p|q) == 0" under...
* fold-const.c (fold_truthop): Transform "a || b" into "(a|b) != 0"
and "!p && !q" into "(p|q) == 0" under suitable conditions.
From-SVN: r54148
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 400285e..0998a93 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3506,7 +3506,29 @@ fold_truthop (code, truth_type, lhs, rhs) && ! FLOAT_TYPE_P (TREE_TYPE (rl_arg)) && simple_operand_p (rl_arg) && simple_operand_p (rr_arg)) - return build (code, truth_type, lhs, rhs); + { + /* Convert (a != 0) || (b != 0) into (a | b) != 0. */ + if (code == TRUTH_OR_EXPR + && lcode == NE_EXPR && integer_zerop (lr_arg) + && rcode == NE_EXPR && integer_zerop (rr_arg) + && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg)) + return build (NE_EXPR, truth_type, + build (BIT_IOR_EXPR, TREE_TYPE (ll_arg), + ll_arg, rl_arg), + integer_zero_node); + + /* Convert (a == 0) && (b == 0) into (a | b) == 0. */ + if (code == TRUTH_AND_EXPR + && lcode == EQ_EXPR && integer_zerop (lr_arg) + && rcode == EQ_EXPR && integer_zerop (rr_arg) + && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg)) + return build (EQ_EXPR, truth_type, + build (BIT_IOR_EXPR, TREE_TYPE (ll_arg), + ll_arg, rl_arg), + integer_zero_node); + + return build (code, truth_type, lhs, rhs); + } /* See if the comparisons can be merged. Then get all the parameters for each side. */ |