Bug 126523 - `(si)~(ui)si_var` should be converted into just ~si_var
Summary: `(si)~(ui)si_var` should be converted into just ~si_var
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 17.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: easyhack, missed-optimization, TREE
Depends on:
Blocks:
 
Reported: 2026-07-30 17:24 UTC by Drea Pinski
Modified: 2026-07-30 18:03 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Drea Pinski 2026-07-30 17:24:51 UTC
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