mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-14 02:29:36 +08:00
fold-const.c (fold_truthop): Optimize bitfield references with different masks as long as their size and bit...
* fold-const.c (fold_truthop): Optimize bitfield references with different masks as long as their size and bit position are the same. From-SVN: r26006
This commit is contained in:
parent
bd910dcf7a
commit
11a86c5688
@ -65,6 +65,9 @@ Fri Mar 26 10:43:47 1999 Nick Clifton <nickc@cygnus.com>
|
||||
|
||||
Fri Mar 26 01:59:15 1999 "Charles M. Hannum" <root@ihack.net>
|
||||
|
||||
* fold-const.c (fold_truthop): Optimize bitfield references with
|
||||
different masks as long as their size and bit position are the same.
|
||||
|
||||
* fold-const.c (fold_truthop): Build a type for both the lhs and
|
||||
rhs and use it appropriately.
|
||||
|
||||
|
@ -3934,25 +3934,24 @@ fold_truthop (code, truth_type, lhs, rhs)
|
||||
size_int (xrr_bitpos), 0);
|
||||
|
||||
/* Make a mask that corresponds to both fields being compared.
|
||||
Do this for both items being compared. If the masks agree,
|
||||
and the bits being compared are in the same position, and the
|
||||
types agree, then we can do this by masking both and comparing
|
||||
the masked results. */
|
||||
Do this for both items being compared. If the operands are the
|
||||
same size and the bits being compared are in the same position
|
||||
then we can do this by masking both and comparing the masked
|
||||
results. */
|
||||
ll_mask = const_binop (BIT_IOR_EXPR, ll_mask, rl_mask, 0);
|
||||
lr_mask = const_binop (BIT_IOR_EXPR, lr_mask, rr_mask, 0);
|
||||
if (operand_equal_p (ll_mask, lr_mask, 0)
|
||||
&& lnbitsize == rnbitsize && xll_bitpos == xlr_bitpos
|
||||
&& lntype == rntype)
|
||||
if (lnbitsize == rnbitsize && xll_bitpos == xlr_bitpos)
|
||||
{
|
||||
lhs = make_bit_field_ref (ll_inner, lntype, lnbitsize, lnbitpos,
|
||||
ll_unsignedp || rl_unsignedp);
|
||||
if (! all_ones_mask_p (ll_mask, lnbitsize))
|
||||
lhs = build (BIT_AND_EXPR, lntype, lhs, ll_mask);
|
||||
|
||||
rhs = make_bit_field_ref (lr_inner, rntype, rnbitsize, rnbitpos,
|
||||
lr_unsignedp || rr_unsignedp);
|
||||
if (! all_ones_mask_p (ll_mask, lnbitsize))
|
||||
{
|
||||
lhs = build (BIT_AND_EXPR, lntype, lhs, ll_mask);
|
||||
rhs = build (BIT_AND_EXPR, rntype, rhs, ll_mask);
|
||||
}
|
||||
if (! all_ones_mask_p (lr_mask, rnbitsize))
|
||||
rhs = build (BIT_AND_EXPR, rntype, rhs, lr_mask);
|
||||
|
||||
return build (wanted_code, truth_type, lhs, rhs);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user