[Bug tree-optimization/126877] New: a==b imples (a+b)&1 is known to 0

"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=126877

            Bug ID: 126877
           Summary: a==b imples (a+b)&1 is known to 0
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: easyhack, missed-optimization, TREE
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 85316
  Target Milestone: ---

Take:
```
signed f(signed a, signed b)
{
    if (a == b)
    {
      signed c = a + b;
      return c&1;
    }
    return 1;
}
```

This should optimize to return a == b. which it does on the RTL level.


A operator_plus::op1_op2_relation_effect needs to be implemented though the
range that is being intersection with is one with a bitmask/value rather than
zero/nonegative (etc.).


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases
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.