https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99776
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- diff --git a/gcc/match.pd b/gcc/match.pd index 036f92fa959..61c93b5edd1 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -6168,9 +6168,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (simplify (BIT_FIELD_REF CONSTRUCTOR@0 @1 @2) (if (VECTOR_TYPE_P (TREE_TYPE (@0)) - && (types_match (type, TREE_TYPE (TREE_TYPE (@0))) + && tree_fits_uhwi_p (TYPE_SIZE (type)) + && ((tree_to_uhwi (TYPE_SIZE (type)) + == tree_to_uhwi (TYPE_SIZE (TREE_TYPE (TREE_TYPE (@0))))) || (VECTOR_TYPE_P (type) - && types_match (TREE_TYPE (type), TREE_TYPE (TREE_TYPE (@0)))))) + && (tree_to_uhwi (TYPE_SIZE (TREE_TYPE (type))) + == tree_to_uhwi (TYPE_SIZE (TREE_TYPE (TREE_TYPE (@0)))))))) (with { tree ctor = (TREE_CODE (@0) == SSA_NAME works to fix the testcase. The issue is that we vectorize pointer data as unsigned long and the type mismatch prevents the folding. With the above FRE4 produces <bb 2> [local count: 118111601]: _10 = (long unsigned int) &a[1]; vect_cst__4 = {_10, _10}; MEM <vector(2) long unsigned int> [(int * *)&c] = vect_cst__4; b = 2; return 0; as desired. Queued for GCC 12.