diff options
author | Charles M. Hannum <root@ihack.net> | 1999-03-26 15:46:33 -0700 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 1999-03-26 15:46:33 -0700 |
commit | 11a86c5688cfcf22c52cf737070a8d3df5a59285 (patch) | |
tree | 9e363eeae831179c59d373004651dd6f32159c23 | |
parent | bd910dcf7a3d8b71c4305c91c22e2e4831554dcf (diff) | |
download | gcc-11a86c5688cfcf22c52cf737070a8d3df5a59285.zip gcc-11a86c5688cfcf22c52cf737070a8d3df5a59285.tar.gz gcc-11a86c5688cfcf22c52cf737070a8d3df5a59285.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/fold-const.c | 23 |
2 files changed, 14 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8822a94..f14f7df 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d96aa3c..9b003c2 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); } |