This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/85929] _GLIBCXX_ASSERTIONS, subscript type mismatch, and std::vector bounds check elimination


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-05-28
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
VRP sees

  long int _16;
  size_type count;

  count_8 = (size_type) _16;
...
  <bb 3> [local count: 593525634]:
  # i_4 = PHI <0(2), i_12(6)>
  if (i_4 >= count_8)
    goto <bb 7>; [11.00%]
  else
    goto <bb 4>; [89.00%]

  <bb 4> [local count: 528237814]:
  i_18 = ASSERT_EXPR <i_4, i_4 < count_8>;
  _1 = (long unsigned int) i_18;
  _21 = (long unsigned int) _16;
...
  if (_1 >= _21)

so we could improve things in vrp_evaluate_conditional and friends by looking
not only at the ops but their definitions.  But the truncation of _16 to
count_8 makes the desired optimization more complicated...  That is,
for > UINT_MAX # of elements the code will infintely loop AFAICS (but it will
not access elements out of bounds).

So somehow we need to enhance the code in VRP that registers additional
asserts to also handle symbolic ranges and thus register not only
i_4 < count_8 but also (long int) i_4 < _16 in a usable form.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]