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

            Bug ID: 114214
           Summary: `(x&~M)|((x&M)&~(y&M))` -> `x&~(y&M)` is not done
           Product: gcc
           Version: 14.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
  Target Milestone: ---

GCC should be able to optimize f to f1:
```
int f(int x, int y, int M)
{
        return (x&~M)|((x&M)&~(y&M));
}
int f1(int x, int y, int M)
{
        return x&~(y&M);
}
```

Note it should be also done for a constant M and when M is a comparison too.

Reply via email to