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/91789] Value ranges determined from comparisons not used transitively
Date: Thu, 16 Dec 2021 03:04:34 +0000	[thread overview]
Message-ID: <bug-91789-4-B1mGH2v0Bw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-91789-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91789

--- Comment #7 from Andrew Macleod <amacleod at redhat dot com> ---
hmm. yeah. we have the knowledge... but how to apply it efficiently.



=========== BB 4 ============
Imports: a_3(D)
Exports: a_3(D)
b_2(D)  int VARYING
a_3(D)  int VARYING
Relational : (b_2(D) >= a_3(D))
    <bb 4> :
    if (a_3(D) < 0)
      goto <bb 5>; [INV]
    else
      goto <bb 6>; [INV]

4->5  (T) a_3(D) :      int [-INF, -1]
4->6  (F) a_3(D) :      int [0, +INF]

We know the relationship upon entry to BB 4, but with no reference to b_2,
there is no reason to update b_2's range.  b_2 may never be reference again.

=========== BB 6 ============
Imports: b_2(D)
Exports: b_2(D)
b_2(D)  int VARYING
    <bb 6> :
    if (b_2(D) < 0)
      goto <bb 7>; [INV]
    else
      goto <bb 8>; [INV]

6->7  (T) b_2(D) :      int [-INF, -1]
6->8  (F) b_2(D) :      int [0, +INF]

And upon entry to BB6, we do know that a_3 is [0, +INF], but with no reference
to a_3 in this block, we don't see any reason to look to see if there is a
relationship.  And with no further references to a_3 in the IL, we wont
propagate its value to here either.


THe problem is that unless we do an exhaustive search of every possible
relation of b_2, there is nothing in the IL at each point to indicate we should
look at the other name.

Perhaps it isnt as bad as I make it sound.

r perhaps I can add relations to the export list for a block and have gori
figure it out.
IE, in bb4  a_3 is the only export, and we can calculate a range for it. 
If we note at this point that there is a relation between a_3 and b_2, perhaps
I can add b_2 to the export list as well, and the GORI how to process the
relation much like it process recalculations.

IF we have c_9 = a_3 - 10 somewhere in the program, we note the dependence of
c_9 on a_3, and we "recalculate" c_9 as [0,+INF] - 10  == [-10, +INF-10] on
that edge.

Perhaps I can likewise add relations to this recomputation and flag b_3 as a
recomputation.. Since the relation is technically "true", it could be solved
for b_2 as 
  [1, 1] = b_2(D) >= [1, +INF] and everything should just work... 
hmm.  
I shall give it a go after a bit more thought.

      parent reply	other threads:[~2021-12-16  3:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-91789-4@http.gcc.gnu.org/bugzilla/>
2020-11-06 22:20 ` amacleod at redhat dot com
2021-12-16  0:09 ` pinskia at gcc dot gnu.org
2021-12-16  3:04 ` amacleod at redhat dot com [this message]

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-91789-4-B1mGH2v0Bw@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: link
Be 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).