https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71307

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
If the BIT_FIELD_REF covers the whole object then it should be simplified to
a VIEW_CONVERT.  There is "related" simplification in match.pd:

(simplify
 (BIT_FIELD_REF @0 @1 @2)
 (switch
  (if (TREE_CODE (TREE_TYPE (@0)) == COMPLEX_TYPE
       && tree_int_cst_equal (@1, TYPE_SIZE (TREE_TYPE (TREE_TYPE (@0)))))
   (switch
    (if (integer_zerop (@2))
     (view_convert (realpart @0)))
    (if (tree_int_cst_equal (@2, TYPE_SIZE (TREE_TYPE (TREE_TYPE (@0)))))
     (view_convert (imagpart @0)))))
  (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
       && INTEGRAL_TYPE_P (type)
       /* On GIMPLE this should only apply to register arguments.  */
       && (! GIMPLE || is_gimple_reg (@0))
       /* A bit-field-ref that referenced the full argument can be stripped. 
*/
       && ((compare_tree_int (@1, TYPE_PRECISION (TREE_TYPE (@0))) == 0
            && integer_zerop (@2))
...
   (convert @0))))

but restricted to integral types as we use convert and not view_convert.

Other than that, BIT_FIELD_REF expansion might simply miss a trick.

Reply via email to