public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/99966] Bounds check not eliminated by assert
Date: Thu, 08 Apr 2021 07:19:45 +0000	[thread overview]
Message-ID: <bug-99966-4-QDExtvuQsx@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99966-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-04-08
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
             Blocks|                            |85316

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
For the testcase the issue is that the range check is inside the loop and
eliminating it requires symbolic range propagation to work "better".

We arrive at

i_28: long unsigned int [_32, +INF]  EQUIVALENCES: { i_1 i_12 } (2 elements)
i_12: size_t VARYING

for

  <bb 2> [local count: 118253447]:
  if (start_4(D) < end_5(D))
    goto <bb 3>; [99.96%]
  else
    goto <bb 4>; [0.04%]

  <bb 3> [local count: 118206146]:
  _9 = MEM[(const struct vector *)data_7(D)].D.18843._M_impl.D.18156._M_finish;
  _8 = MEM[(const struct vector *)data_7(D)].D.18843._M_impl.D.18156._M_start;
  _14 = _9 - _8;
  _15 = _14 /[ex] 8;
  _16 = (long unsigned int) _15;
  _33 = _16 >= end_5(D);
  _34 = _16 > start_4(D);
  _22 = _33 & _34;
  if (_22 != 0)
    goto <bb 7>; [99.92%]
  else
    goto <bb 4>; [0.08%]

  <bb 4> [local count: 141847]:
  __assert_fail ("start < end && start < data.size() && end <= data.size()",
"t.C", 7, "uint64_t f(std::vector<long unsigned int>&, size_t, size_t)");

  <bb 5> [local count: 834435851]:
  if (i_12 >= _16)
    goto <bb 6>; [0.05%]
  else
    goto <bb 7>; [99.95%]

  <bb 6> [local count: 381018]:
  # i_38 = PHI <i_12(5)>
  std::__throw_out_of_range_fmt ("vector::_M_range_check: __n (which is %zu) >=
this->size() (which is %zu)", i_38, _16);

  <bb 7> [local count: 952166435]:
  # total_3 = PHI <total_11(5), 0(3)>
  # i_2 = PHI <i_12(5), start_4(D)(3)>
  _10 = MEM[(value_type &)_8 + i_2 * 8];
  total_11 = total_3 + _10;
  i_12 = i_2 + 1;
  if (i_12 != end_5(D))
    goto <bb 5>; [87.64%]
  else
    goto <bb 8>; [12.36%]

  <bb 8> [local count: 117730583]:
  # total_37 = PHI <total_11(7)>
  return total_37;


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases

  reply	other threads:[~2021-04-08  7:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08  1:23 [Bug tree-optimization/99966] New: " jmuizelaar at mozilla dot com
2021-04-08  7:19 ` rguenth at gcc dot gnu.org [this message]
2022-01-11 18:59 ` [Bug tree-optimization/99966] " amacleod at redhat dot com
2022-11-03 19:31 ` amacleod at redhat dot com
2022-11-28 22:09 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-99966-4-QDExtvuQsx@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).