public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "amacleod at redhat dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/85315] missed range optimisation opportunity for derefences where index must be 0 or otherwise constrained Date: Wed, 18 Nov 2020 14:55:44 +0000 [thread overview] Message-ID: <bug-85315-4-0Ex3RMF3oS@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-85315-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85315 --- Comment #12 from Andrew Macleod <amacleod at redhat dot com> --- Maybe I'm a little dense. if we are presuming that &x + (a + b) implies a + b == 0, then we also should assume that &x + a implies a == 0 and if we can make those assumptions, then &x + 1 is garbage because we can assume 1 == 0. And if a and b are both unsigned, then I guess we can also assume a == b == MAX_UINT / 2 ? Now, if we decided to actually do this... I see IL: <bb 2> : x.0_1 = x; y = x.0_1; a.1_2 = a; b.2_3 = b; _4 = a.1_2 + b.2_3; _5 = (long unsigned int) _4; _6 = _5 * 4; _7 = &y + _6; The clear implications is that _6 == 0 in this expression? If we implemented that in the operator_pointer_plus::op1_range routine, and then were to back substitute, we'd get (_6)[0,0] = _5 * 4 -> _5 = [0,0] (_5)[0,0] = (long unsigned int) _4; -> _4 == [0,0] (_4)[0,0] = a.1_2 + b.2_3 which gives us nothing additional... Other than a potential relationship to track I suppose a.1_2 == -B.2_3 for signed, but it would record that _4 is [0,0] when we calculate an outgoing range. but regardless, its seems that another straightforward place to do this would be in statement folding? Isn't the basic assumption: _7 = &y + _6; implies _6 is always 0, which would enable us to fold this to _7 = &y then _6 is unused and the other statements would ultimately just go away. So why not make folding simply throw away the "+ _6" part because it is now being forced to be 0? We can't really assume that it is [0,0], but then not use that information to optimize?
next prev parent reply other threads:[~2020-11-18 14:55 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-85315-4@http.gcc.gnu.org/bugzilla/> 2020-11-17 17:42 ` amacleod at redhat dot com 2020-11-18 7:37 ` rguenth at gcc dot gnu.org 2020-11-18 14:55 ` amacleod at redhat dot com [this message] 2020-11-18 15:17 ` jakub at gcc dot gnu.org 2020-11-18 15:46 ` msebor at gcc dot gnu.org 2020-11-18 19:05 ` rguenther at suse dot de 2020-11-19 16:24 ` amacleod at redhat 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-85315-4-0Ex3RMF3oS@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).