public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/90436] Redundant size checking in vector Date: Sun, 21 Jun 2020 17:13:57 +0000 [thread overview] Message-ID: <bug-90436-4-ZIGE7pmXV5@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-90436-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90436 --- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> --- // possibly assumes that ptrdiff_t and size_t have the same size size_type _M_check_len_one(const char* __str) const { ptrdiff_t __n = sizeof(_Tp); ptrdiff_t __ms = max_size(); __ms *= sizeof(_Tp); ptrdiff_t __s = size(); __s *= sizeof(_Tp); if (__s > (__ms - __n)) __throw_length_error(__N(__str)); const ptrdiff_t __len = __s + (std::max)(__s, __n); if (__len <= 0) __builtin_unreachable(); ptrdiff_t __ret = (std::min)(__len, __ms); return (_Tp*)__ret-(_Tp*)0; // hack to generate divexact, so it simplifies with * sizeof(_Tp) } generates nicer code. But after those experiments, it seems clear that the performance of this code is irrelevant (not surprising since it is followed by a call to operator new), and its effect on global performance is random. Possibly it causes something to get aligned differently, which can randomly get this 25% speed-up, but can just as randomly go back to the slow version. Anyway, I don't think I'll be submitting any patch for this.
next prev parent reply other threads:[~2020-06-21 17:13 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-90436-4@http.gcc.gnu.org/bugzilla/> 2020-06-19 22:35 ` glisse at gcc dot gnu.org 2020-06-21 17:13 ` glisse at gcc dot gnu.org [this message] 2020-06-21 18:03 ` glisse 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-90436-4-ZIGE7pmXV5@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: linkBe 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).