On 12/7/22 06:54, Richard Biener via Gcc-patches wrote:
The following avoids CSE of &ps->wp to &ps->wp.hwnd confusing
-Wstringopt-overflow by making sure to produce addresses to the
biggest container from vectorization.  For this I introduce
strip_zero_offset_components which turns &ps->wp.hwnd into
&(*ps) and use that to base the vector data references on.
That will also work for addresses with variable components,
alternatively emitting pointer arithmetic via calling
get_inner_reference and gimplifying that would be possible
but likely more intrusive.

This is by no means a complete fix for all of those issues
(avoiding ADDR_EXPRs in favor of pointer arithmetic might be).
Other passes will have similar issues.

In theory that might now cause false negatives.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Any opinion?

Thanks,
Richard.

        PR tree-optimization/106904
        * tree.h (strip_zero_offset_components): Declare.
        * tree.cc (strip_zero_offset_components): Define.
        * tree-vect-data-refs.cc (vect_create_addr_base_for_vector_ref):
        Strip zero offset components before building the address.

        * gcc.dg/Wstringop-overflow-pr106904.c: New testcase.
So you're just canonicalizing to the widest container for a zero offset access. While it may not fix everything, that seems like a good thing in general when we can do so. I wouldn't be surprised if other passes could do the same thing to fix some of the missed CSE opportunities.

jeff

Reply via email to