[Bug libstdc++/90436] Redundant size checking in vector
glisse at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jun 21 18:03:59 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90436
--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> ---
(side note not related to the redundant size checking)
It is surprising how, in the code from comment 2, adding v.reserve(1000) does
not help, it even slows the program down slightly here (yes, that's rather hard
to believe). To reap the benefits, I also need to add in the loop:
if(v.size()==v.capacity())__builtin_abort();
which enables the compiler to remove the reallocation code, and once that code
is removed it can actually prove that size never reaches capacity and remove
the call to abort! We don't even need __builtin_unreachable there. And once all
that dead code is removed, it can finally vectorize.
More information about the Gcc-bugs
mailing list