From 5a6b336594790cb0c4edc5207fa344acb053923c Mon Sep 17 00:00:00 2001 From: "J\"orn Rennecke" Date: Thu, 13 Nov 1997 00:09:37 +0000 Subject: 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 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'gcc') 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 + + * 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; } -- cgit v1.1