public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102155] New: LIM fill_always_executed_in handles contains_call incorrectly Date: Wed, 01 Sep 2021 07:09:29 +0000 [thread overview] Message-ID: <bug-102155-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102155 Bug ID: 102155 Summary: LIM fill_always_executed_in handles contains_call incorrectly Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- fill_always_executed_in walks loop bodies in dominator order (get_loop_body_in_dom_order) but that does not run into BB3 before marking BB4 as always executed: do { BB1: if (x) BB2: if (y) BB3: bar(); BB4; } while (++i < n); the dominator children of BB1 are BB2 and BB4, BB3 with the call to bar() is only a dominator child of BB2. Since LIM gives up on "unanalyzable" refs like calls a testcase that is miscompiled is a bit difficult to construct - it requires a 'pure' (or const) call but whether it's valid for those to exit the program could be subject to discussion. The following uses a looping const function to show the effect and the testcase segfaults with -O1+ while it runs into the infinite loop at -O0. Note we'd technically need to set looping_const but there's now way to do this and with just -fno-inline and letting IPA figure out looping-const dominator children are ordered in a "lucky" way for fill_sons_in_loop to compute an order that happens to work. extern void abort (void); int flag[32]; int __attribute__((noinline,const)) bar (int i) { if (i) return i; while (1); } int __attribute__((noipa)) foo (int *p, int n) { int i = 0, res = 0; do { if (!flag[i]) { if (i % 3 == 0) res += bar (i); else res++; } res += *p; } while (++i < n); return res; } int main() { if (foo ((int *)0, 5) != 0) abort (); return 0; }
next reply other threads:[~2021-09-01 7:09 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-01 7:09 rguenth at gcc dot gnu.org [this message] 2021-09-01 7:58 ` [Bug tree-optimization/102155] " rguenth at gcc dot gnu.org 2021-09-02 5:55 ` cvs-commit at gcc dot gnu.org 2021-09-02 7:56 ` 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-102155-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).