diff options
author | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-03-26 22:46:33 +0000 |
---|---|---|
committer | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-03-26 22:46:33 +0000 |
commit | 00ee092150e7465e448dc8c8ba5dee6ad7b3652c (patch) | |
tree | 9e363eeae831179c59d373004651dd6f32159c23 /gcc/fold-const.c | |
parent | ffba564ca887f9a98557caa492ec78efe410e990 (diff) | |
download | ppe42-gcc-00ee092150e7465e448dc8c8ba5dee6ad7b3652c.tar.gz ppe42-gcc-00ee092150e7465e448dc8c8ba5dee6ad7b3652c.zip |
* fold-const.c (fold_truthop): Optimize bitfield references with
different masks as long as their size and bit position are the same.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26006 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d96aa3c8279..9b003c2ec22 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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); } |