public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jeffreyalaw at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107114] New: [13 Regression] Failure to discover range results in bogus warning Date: Sat, 01 Oct 2022 17:59:31 +0000 [thread overview] Message-ID: <bug-107114-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107114 Bug ID: 107114 Summary: [13 Regression] Failure to discover range results in bogus warning Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jeffreyalaw at gmail dot com CC: aldyh at redhat dot com, amacleod at redhat dot com Target Milestone: --- Target: arc-elf After this change (from me): aa360fbf68b11e54017e8fa5b1bdb87ce7c19188 I'm seeing a case on arc-elf where VRP/Ranger is no longer identifying the range of one object as not including zero. As a result a test later in the CFG isn't simplified and we get a bogus warning. What's really interesting here is my change simplifies the CFG by eliminating a handful of blocks in the affected loop (including a sub-loop). Here's the testcase: /* { dg-do compile } */ short a; long b; void fn1() { int c = a = 1; for (; a; a++) { for (; 9 <= 8;) for (;;) { a = 20; for (; a <= 35; a++) ; line:; } if ((c += 264487869) == 9) { unsigned *d = 0; for (; b;) d = (unsigned *)&c; if (d) for (;;) ; } } goto line; } Compiled on arc-elf with -Os -Wall: [jlaw@X10DRH-iT gcc]$ ./cc1 -Os -Wall k.c -quiet k.c: In function ‘fn1’: k.c:17:14: warning: iteration 8 invokes undefined behavior [-Waggressive-loop-optimizations] 17 | if ((c += 264487869) == 9) | ^~ k.c:8:10: note: within this loop 8 | for (; a; a++) | ^ If we look at the .vrp2 dump before my change we have this: Global Exported: a_lsm.14_26 = [irange] short int [1, 9] NONZERO 0xf This is key because we have this in the CFG: ;; basic block 7, loop depth 1, count 21262216 (estimated locally), maybe hot ;; prev block 6, next block 1, flags: (NEW, REACHABLE, VISITED) ;; pred: 2 [always] count:1346238 (estimated locally) (FALLTHRU,EXECUTABLE) k.c:8:3 ;; 6 [always] count:20092794 (estimated locally) (FALLTHRU,DFS_BACK,EXECUTABLE) # a_lsm.14_26 = PHI <1(2), _11(6)> # a_lsm_flag.15_28 = PHI <0(2), 1(6)> # c_lsm.16_29 = PHI <1(2), _6(6)> if (a_lsm.14_26 != 0) goto <bb 6>; [94.50%] else goto <bb 3>; [5.50%] We really want to simplify that condition to a compile-time constant. That avoids the incorrect warning. After my change we do not discover the range for a_lsm.14_26 in vfp2 and naturally conditional above isn't simplified and the warning gets triggered. Maybe I'm missing something subtle, but it looks like the simplifications done in dom3 are resulting in vrp2 missing discovery of the key range. It's not clear to me why that's that's happening though. Thoughts?
next reply other threads:[~2022-10-01 17:59 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-01 17:59 jeffreyalaw at gmail dot com [this message] 2022-10-01 18:01 ` [Bug tree-optimization/107114] " law at gcc dot gnu.org 2022-10-03 15:46 ` amacleod at redhat dot com 2022-10-03 17:37 ` law at gcc dot gnu.org 2022-10-03 18:18 ` amacleod at redhat dot com 2022-10-03 18:21 ` law at gcc dot gnu.org 2022-10-06 9:27 ` rguenth at gcc dot gnu.org 2022-12-22 14:32 ` rguenth at gcc dot gnu.org 2023-02-21 13:51 ` 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-107114-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).