[Bug tree-optimization/126704] New: Missing or not complete global range after VRP2 (with and without dom)

"pinskia at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126704

            Bug ID: 126704
           Summary: Missing or not complete global range after VRP2 (with
                    and without dom)
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 85316, 126010
  Target Milestone: ---

Take:
```
int
Foo (int *p, int t)
{
  int i = *p;
  if (! (i <= 99999))
    __builtin_unreachable ();
  if (! (0 <= i && i <= 99999))
    __builtin_unreachable ();
  return i/10;
}

```

While working on changing tree_single_nonnegative_p over to use the ranger I
noticed this. This comes from `gcc.dg/pr80776-1.c` but changed to force the use
of the range after VRP2.

at -O2 at VRP2, the global range for the load will be `[-INF, 99999]` which is
what dom had set and is not updated afterwards.

With `-O2 -fno-tree-dominator-opts`, the global range will be gone.

This causes us not to notice that i is non-negative while expanding.
So the issue here is 2 fold, if we remove dom, we will remove sometimes partial
ranges but even those are partial ranges which is not updated by VRP2.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126010
[Bug 126010] [meta-bug] Remove DOM
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.