public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pterjan at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/96326] New: Incorrect loop optimization at -O3 Date: Mon, 27 Jul 2020 01:27:54 +0000 [thread overview] Message-ID: <bug-96326-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96326 Bug ID: 96326 Summary: Incorrect loop optimization at -O3 Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pterjan at gmail dot com Target Milestone: --- Found in https://github.com/Sereal/Sereal/issues/229 #include <string.h> #include <stdio.h> int main() { char buf[128]; char *src = buf; char *op = buf + 3; int len = 64; strcpy(buf, "abc"); while (op - src < 8) { *(unsigned long*)op = *(const unsigned long*)src; len -= op - src; op += op - src; } while (len > 0) { *(unsigned long*)op = *(const unsigned long*)src; src += 8; op += 8; len -= 8; } printf("%ld\n", strlen(buf)); } $ gcc -O2 -Wall t.c; ./a.out 68 $ gcc -O3 -Wall t.c; ./a.out 24 Adding a printf in the second loop also fixes it.
next reply other threads:[~2020-07-27 1:27 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-27 1:27 pterjan at gmail dot com [this message] 2020-07-27 1:36 ` [Bug middle-end/96326] " pinskia at gcc dot gnu.org 2020-07-27 1:48 ` pterjan at gmail dot com 2020-07-27 6:41 ` [Bug middle-end/96326] [10/11 Regression] Incorrect loop optimization at -O3 since r10-4803-g8489e1f45b50600c marxin at gcc dot gnu.org 2020-07-27 7:43 ` rguenth 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-96326-4@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).