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/68136] missed tree-level optimization with redundant computations Date: Wed, 28 Oct 2015 15:04:00 -0000 [thread overview] Message-ID: <bug-68136-4-WsZPWPRnrs@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-68136-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68136 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2015-10-28 CC| |rguenth at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- int foo (s64 a, s64 b, s64 c) { s64 d = a - b; if (d == 0) return a + c; else return b + d + c; } ok, so the issue here is that the additions are narrowed to unsigned int because of the appearant cast to 'int' for the return while the d = a - b assignment is not narrowed in this way. (u32)b + (u32)(a - b) + (u32)c can not be easily simplified to the desired (u32)a + (u32)c. As 'd' is multi-use this way we don't change the compare to a == b either which would expose the then single-use 'd' to reassoc (which could get some tricks to perform narrowing). I don't see a very good answer here. Pattern-matching the whole thing is of course an option but I don't see that as a scalable solution. Maybe hacking up reassoc to do that narrowing trick and also consider non-single-use chains (marked specially so they only participate in simplification but never actual association or code-gen).
next prev parent reply other threads:[~2015-10-28 15:04 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-10-28 14:39 [Bug tree-optimization/68136] New: " ktkachov at gcc dot gnu.org 2015-10-28 14:39 ` [Bug tree-optimization/68136] " ktkachov at gcc dot gnu.org 2015-10-28 15:04 ` rguenth at gcc dot gnu.org [this message] 2021-07-26 23:08 ` pinskia 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-68136-4-WsZPWPRnrs@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).