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

--- Comment #4 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:c250ff90989a71dff11e9256e99d2fa965ab1295

commit r14-6360-gc250ff90989a71dff11e9256e99d2fa965ab1295
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Sat Dec 9 21:41:00 2023 +0100

    phiopt: Fix ICE with large --param l1-cache-line-size= [PR112887]

    This function is never called when param_l1_cache_line_size is 0,
    but it uses int and unsigned int variables to hold alignment in
    bits, so for large param_l1_cache_line_size it is zero and e.g.
    DECL_ALIGN () % param_align_bits can divide by zero.
    Looking at the code, the function uses tree_fits_uhwi_p on the trees
    before converting them using tree_to_uhwi to int variables, which
    looks just wrong, either it would need to punt if it doesn't fit
    into those and also check for overflows during the computation,
    or use unsigned HOST_WIDE_INT for all of this.  That also fixes
    the division by zero, as param_l1_cache_line_size maximum is INT_MAX,
    that multiplied by 8 will always fit.

    2023-12-09  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/112887
            * tree-ssa-phiopt.cc (hoist_adjacent_loads): Change type of
            param_align, param_align_bits, offset1, offset2, size2 and align1
            variables from int or unsigned int to unsigned HOST_WIDE_INT.

            * gcc.dg/pr112887.c: New test.

Reply via email to