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

            Bug ID: 113189
           Summary: `(-X * Y) * -X` can be optimized to `(X * Y) * X`
           Product: gcc
           Version: 14.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:
```
int f(int X, int Y)
{
        return (-X * Y) * -X;
}
double fd(double X, double Y)
{
        return (-X * Y) * -X;
}

int g(int X, int Y)
{
        return ((-X) << Y) * -X;
}
```

The negative should be optimized away but currently is only optimized at the
RTL level.

Reply via email to