public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "DeusExSophismata at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/38470] value range propagation (VRP) would improve -Wsign-compare Date: Sat, 24 Mar 2012 07:50:00 -0000 [thread overview] Message-ID: <bug-38470-4-9ZenZ9A1Fu@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-38470-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 David Stone <DeusExSophismata at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |DeusExSophismata at gmail | |dot com --- Comment #10 from David Stone <DeusExSophismata at gmail dot com> 2012-03-24 06:52:04 UTC --- Simple self-contained test case: unsigned f (int x) { return (x >= 0) ? x : -x; } int main () { return 0; } It seems like we could at least add a simple improvement that just checks for simple comparisons to 0. That probably catches most code (I often do one set of calculations for non-negative values, and another set for negative values) and avoids a lot of problems of trying to track complex calculations for the signedness of the result. I wouldn't be perfect, but it would be better than it currently is. Being able to detect cases like this is also an optimization opportunity, because division with positive integers is simpler than division with negative integers, for example. We could reuse code that detects that optimization opportunity for this warning.
next prev parent reply other threads:[~2012-03-24 6:52 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-38470-4@http.gcc.gnu.org/bugzilla/> 2011-06-15 18:16 ` manu at gcc dot gnu.org 2012-03-24 7:50 ` DeusExSophismata at gmail dot com [this message] 2012-04-16 10:44 ` manu at gcc dot gnu.org 2013-05-20 13:23 ` paolo.carlini at oracle dot com 2015-01-07 11:11 ` manu at gcc dot gnu.org 2015-06-22 10:41 ` manu at gcc dot gnu.org 2020-05-06 8:45 ` kretz at kde dot org 2020-05-06 8:46 ` kretz at kde dot org 2020-11-03 4:14 ` egallager at gcc dot gnu.org 2021-06-28 13:01 ` inkerman42 at gmail dot com 2021-06-28 13:51 ` mkretz at gcc dot gnu.org 2021-06-28 14:13 ` vincent-gcc at vinc17 dot net 2021-06-28 14:30 ` mkretz at gcc dot gnu.org 2021-06-28 14:53 ` vincent-gcc at vinc17 dot net 2021-06-28 15:07 ` mkretz at gcc dot gnu.org 2021-06-28 15:33 ` vincent-gcc at vinc17 dot net 2008-12-10 10:35 [Bug c/38470] New: Feature request: smarter signed/unsigned warning m dot j dot thayer at googlemail dot com 2010-02-24 14:11 ` [Bug c/38470] value range propagation (VRP) would improve -Wsign-compare manu at gcc dot gnu dot org 2010-02-24 14:13 ` manu at gcc dot gnu dot org 2010-02-24 14:17 ` m dot j dot thayer at googlemail dot com
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-38470-4-9ZenZ9A1Fu@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).