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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:6bebb3b0f3fa422d248a1c2075da0598a44c7320

commit r15-5821-g6bebb3b0f3fa422d248a1c2075da0598a44c7320
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Sat Nov 30 11:30:08 2024 +0100

    strlen: Handle vector CONSTRUCTORs [PR117057]

    The following patch handles VECTOR_TYPE_P CONSTRUCTORs in
    count_nonzero_bytes, including handling them if they have some elements
    non-constant.
    If there are still some constant elements before it (in the range queried),
    we derive info at least from those bytes and consider the rest as unknown.

    The first 3 hunks just punt in IMHO problematic cases, the spaghetti code
    considers byte_size 0 as unknown size, determine yourself, so if offset
    is equal to exp size, there are 0 bytes to consider (so nothing useful
    to determine), but using byte_size 0 would mean use any size.
    Similarly, native_encode_expr uses int type for offset (and size), so
    padding it offset larger than INT_MAX could be silent miscompilation.

    I've guarded the test to just a couple of targets known to handle it,
    because e.g. on ia32 without -msse forwprop1 seems to lower the CONSTRUCTOR
    into 4 BIT_FIELD_REF stores and I haven't figured out on what exactly
    that depends on (e.g. powerpc* is fine on any CPUs, even with -mno-altivec
    -mno-vsx, even -m32).

    2024-11-30  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/117057
            * tree-ssa-strlen.cc (strlen_pass::count_nonzero_bytes): Punt also
            when byte_size is equal to offset or nchars.  Punt if offset is
bigger
            than INT_MAX.  Handle vector CONSTRUCTOR with some elements
constant,
            possibly followed by non-constant.

            * gcc.dg/strlenopt-32.c: Remove xfail and
vect_slp_v2qi_store_unalign
            specific scan-tree-dump-times directive.
            * gcc.dg/strlenopt-96.c: New test.

Reply via email to