summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1999-05-17 01:24:24 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1999-05-17 01:24:24 +0000
commit68ae709da868f20aab6557e7e71c343b8e2c8aa9 (patch)
treef8907ef1b969d9f5b82492ab42a1e22c391b4c66 /gcc/fold-const.c
parent6e0d5d67954481d8f0f7acce942cbbdc362ca1b2 (diff)
downloadgcc-68ae709da868f20aab6557e7e71c343b8e2c8aa9.tar.gz
* fold-const.c (fold_truthop): When converting a one-bit
comparison don't sign extend the constant. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26962 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index b7720f745a5..6acbe0baf34 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3806,30 +3806,25 @@ fold_truthop (code, truth_type, lhs, rhs)
{
if (l_const && integer_zerop (l_const) && integer_pow2p (ll_mask))
{
- if (ll_unsignedp || tree_log2 (ll_mask) + 1 < ll_bitsize)
- 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)));
+ /* Do not sign extend the constant here. The left operand
+ is either always unsigned or there is a BIT_AND_EXPR that
+ masks out the extension bits. */
+ if (! (ll_unsignedp || ll_and_mask != 0))
+ abort ();
+ l_const = ll_mask;
}
else
return 0;
}
+ /* This is analogous to the code for l_const above. */
if (rcode != wanted_code)
{
if (r_const && integer_zerop (r_const) && integer_pow2p (rl_mask))
{
- if (rl_unsignedp || tree_log2 (rl_mask) + 1 < rl_bitsize)
- 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)));
+ if (! (rl_unsignedp || rl_and_mask != 0))
+ abort ();
+ r_const = rl_mask;
}
else
return 0;