[Bug tree-optimization/126523] New: `(si)~(ui)si_var` should be converted into just ~si_var

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

            Bug ID: 126523
           Summary: `(si)~(ui)si_var` should be converted into just
                    ~si_var
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
typedef int si;
typedef unsigned ui;

si f(si a)
{
    ui t = a;
    t = ~t;
    si a1 = t;
    return a1;
}

si f1(si a)
{
    return ~a;
}

int g(si a)
{
    return f(a) + f1(a) == (si)(2*(~a));
}
```
g should optimize to 1 which it does on the RTL level
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.