[Bug tree-optimization/99966] Bounds check not eliminated by assert
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Apr 8 07:19:45 GMT 2021
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
More information about the Gcc-bugs
mailing list