public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/51721] -Warray-bounds false positives and inconsistencies Date: Sat, 31 Dec 2011 17:25:00 -0000 [thread overview] Message-ID: <bug-51721-4-NZcvGPESeL@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-51721-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51721 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-12-31 13:42:55 UTC --- This is a common problem with the -Warray-bounds warning, first jump threading (during vrp1) optimizes it into just a single s == 17 check, followed by a[11] = 0; b[11] = 0; c[17] = 0; d[11] = 0; if true and a[s] = 0; etc. if false (well, at the end of vrp1 the constants aren't in the array refs yet, but they are propagated there afterwards), and as no optimization figures out the weird if (s >> 1 == 0) check (if (s < 2) would DTRT) to determine that s is not 17, vrp2 warns about those accesses. Perhaps for -Warray-bounds (at least if not -Warray-bounds=2 or similar) we shouldn't warn on code that has been jump threaded, anyway, I don't think that is solvable for 4.7 easily. What we perhaps could do more easily for this testcase (and could improve code too) is during VRP for: <bb 2>: D.1716_2 = s_1(D) >> 1; if (D.1716_2 == 0) goto <bb 3>; else goto <bb 12>; (or any other constant after >>, both signed and unsigned right shift, and == or !=) insert ASSERT_EXPRs into both bbs, saying that the SSA_NAME in rhs1 of the shift is in/out of second ==/!= operand << rhs2 of shift, -""- + ((1 << rhs2) - 1) range. In this case it would be ASSERT_EXPRs that s_1(D) <= 1 at the start of bb 3 (and if bb 12 had only one predecessor, also that s_1(D) > 1 at bb 12 start). Richard, what do you think about that?
next prev parent reply other threads:[~2011-12-31 13:43 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-12-31 1:51 [Bug tree-optimization/51721] New: " vincent-gcc at vinc17 dot net 2011-12-31 1:55 ` [Bug tree-optimization/51721] " vincent-gcc at vinc17 dot net 2011-12-31 17:25 ` jakub at gcc dot gnu.org [this message] 2012-01-01 0:18 ` jakub at gcc dot gnu.org 2012-01-02 10:19 ` rguenth at gcc dot gnu.org 2012-01-02 10:25 ` jakub at gcc dot gnu.org 2012-01-03 10:18 ` jakub at gcc dot gnu.org 2012-03-05 12:29 ` jakub at gcc dot gnu.org 2012-03-12 11:13 ` jakub at gcc dot gnu.org 2012-11-09 23:26 ` steven 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-51721-4-NZcvGPESeL@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).