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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #5 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
For testcase from #1 we compile _M_check_len to:
  <bb 4> [local count: 187153200]:
  _13 = MEM[(const struct vector *)v_3(D)].D.25570._M_impl.D.24881._M_start;
  _14 = _6 - _13;
  __dif_15 = _14 /[ex] 4;
  _16 = (long unsigned int) __dif_15;
  if (_16 == 2305843009213693951)
    goto <bb 5>; [0.00%]
  else
    goto <bb 6>; [100.00%]

  <bb 5> [count: 0]:
  std::__throw_length_error ("vector::_M_realloc_append");

  <bb 6> [local count: 187153200]:
  _17 = MAX_EXPR <_16, 1>;
  __len_18 = _16 + _17;
  _19 = MIN_EXPR <__len_18, 2305843009213693951>;

Which seems quite good to me.

Testcase from #2 has runtime 0.466s for gcc 11, 12 and 13. GCC 14 and trunk has
0.409s (I think mostly the _M_realloc_append and _M_check_len work).
Clang does 0.608s with libstdc++ and 0.432s with libc++.

Adding v.reserve(1000) now improves code to 0.231s also since GCC14. 
For clang it makes no difference with libstdc++ and with libc++ it improves to
0.235s, too.

So I think this PR should be solved.

Reply via email to