The following adds some simple BIT_FIELD_REF canonicalization patterns that fire during SCCVN expression simplification.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2018-07-24 Richard Biener <rguent...@suse.de> * match.pd: Add BIT_FIELD_REF canonicalizations. Index: gcc/match.pd =================================================================== --- gcc/match.pd (revision 262940) +++ gcc/match.pd (working copy) @@ -4659,6 +4659,19 @@ (define_operator_list COND_TERNARY /* Canonicalizations of BIT_FIELD_REFs. */ (simplify + (BIT_FIELD_REF (BIT_FIELD_REF @0 @1 @2) @3 @4) + (BIT_FIELD_REF @0 @3 { const_binop (PLUS_EXPR, bitsizetype, @2, @4); })) + +(simplify + (BIT_FIELD_REF (view_convert @0) @1 @2) + (BIT_FIELD_REF @0 @1 @2)) + +(simplify + (BIT_FIELD_REF @0 @1 integer_zerop) + (if (tree_int_cst_equal (@1, TYPE_SIZE (TREE_TYPE (@0)))) + (view_convert @0))) + +(simplify (BIT_FIELD_REF @0 @1 @2) (switch (if (TREE_CODE (TREE_TYPE (@0)) == COMPLEX_TYPE