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

            Bug ID: 112271
           Summary: Some `(a == CST) ? a OP b : CST` is not done in match
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
/* 
a == -1 ? a | b : -1 -> -1
*/
int f_or(int a, int b)
{
  int c = b|a;
  int d;
  if (a == -1) d = c; else d = -1;
  return d;
}
/* 
a == 0 ? a * b : 0 -> 0
*/
int f_mult(int a, int b)
{
  int c = b*a;
  int d;
  if (a == 0) d = c; else d = 0;
  return d;
}
/* 
a == 0 ? a & b : 0 -> 0
*/
int f_and(int a, int b)
{
  int c = b&a;
  int d;
  if (a == 0) d = c; else d = 0;
  return d;
}

```
These all should be done in match. They are currently handled by the ranger
code (either via dom2 or evrp). Matching it in match would allow it to be
caught earlier for -O1 and might allow for some other cases later on.

Recording this here for now so I don't forget to add them ...

Reply via email to