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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org

--- Comment #30 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's LIM2 which applies store-motion to m[0] but keeps m[p] in the loop.
Then with range-info for the int128 of [0, +INF] we get into
get_ref_base_and_extent:

                query = get_range_query (cfun);

                if (TREE_CODE (index) == SSA_NAME
                    && (low_bound = array_ref_low_bound (exp),
                        poly_int_tree_p (low_bound))
                    && (unit_size = array_ref_element_size (exp),
                        TREE_CODE (unit_size) == INTEGER_CST)
                    && query->range_of_expr (vr, index)
                    && !vr.varying_p ()
                    && !vr.undefined_p ())
                  {
                    wide_int min = vr.lower_bound ();
                    wide_int max = vr.upper_bound ();
                    poly_offset_int lbound = wi::to_poly_offset (low_bound);
                    /* Try to constrain maxsize with range information.  */
                    offset_int omax
                      = offset_int::from (max, TYPE_SIGN (TREE_TYPE (index)));
                    if (known_lt (lbound, omax))
                      {
                        poly_offset_int rmaxsize;
                        rmaxsize = (omax - lbound + 1)
                            * wi::to_offset (unit_size) << LOG2_BITS_PER_UNIT;
                        if (!known_size_p (maxsize)
                            || known_lt (rmaxsize, maxsize))

and compute rmaxsize == 0.

What's definitely questionable here is the offset_int::from, though it
fits.  But omax - lbound + 1 overflows to zero here.  It's probably
better to use widest-int here, even if that's possibly slower than
offset_int.  Or ensure offset_int has one more bit than required for
the index type (offset_int has 64bit + 3bits, so 128bits).

Reply via email to