diff options
author | J"orn Rennecke <amylaar@cygnus.co.uk> | 1997-11-13 00:09:37 +0000 |
---|---|---|
committer | Joern Rennecke <amylaar@gcc.gnu.org> | 1997-11-13 00:09:37 +0000 |
commit | 5a6b336594790cb0c4edc5207fa344acb053923c (patch) | |
tree | daaa297a19a53f9e6130ab58d138f37b3ab4732d | |
parent | 2bd3bc6f5c634b1949a06ff4dfca331b990b10f4 (diff) | |
download | gcc-5a6b336594790cb0c4edc5207fa344acb053923c.zip gcc-5a6b336594790cb0c4edc5207fa344acb053923c.tar.gz gcc-5a6b336594790cb0c4edc5207fa344acb053923c.tar.bz2 |
fold-const.c (fold_truthop): When changing a one-bit comparison against zero into a comparison against mask...
* fold-const.c (fold_truthop): When changing a one-bit comparison
against zero into a comparison against mask, do a proper sign
extension.
From-SVN: r16448
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 21 |
2 files changed, 25 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0893da3..af1f8f2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +Thu Nov 13 00:06:58 1997 J"orn Rennecke <amylaar@cygnus.co.uk> + + * fold-const.c (fold_truthop): When changing a one-bit comparison + against zero into a comparison against mask, do a proper sign + extension. + Wed Nov 12 09:37:01 1997 Jeffrey A Law (law@cygnus.com) * except.c: Do not include "assert.h". diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3ce114b..9b34252 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3424,7 +3424,17 @@ fold_truthop (code, truth_type, lhs, rhs) if (lcode != wanted_code) { if (l_const && integer_zerop (l_const) && integer_pow2p (ll_mask)) - l_const = ll_mask; + { + if (ll_unsignedp) + l_const = ll_mask; + else + /* Since ll_arg is a single bit bit mask, we can sign extend + it appropriately with a NEGATE_EXPR. + l_const is made a signed value here, but since for l_const != NULL + lr_unsignedp is not used, we don't need to clear the latter. */ + l_const = fold (build1 (NEGATE_EXPR, TREE_TYPE (ll_arg), + convert (TREE_TYPE (ll_arg), ll_mask))); + } else return 0; } @@ -3432,7 +3442,14 @@ fold_truthop (code, truth_type, lhs, rhs) if (rcode != wanted_code) { if (r_const && integer_zerop (r_const) && integer_pow2p (rl_mask)) - r_const = rl_mask; + { + if (rl_unsignedp) + r_const = rl_mask; + else + /* This is analogous to the code for l_const above. */ + r_const = fold (build1 (NEGATE_EXPR, TREE_TYPE (rl_arg), + convert (TREE_TYPE (rl_arg), rl_mask))); + } else return 0; } |