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

            Bug ID: 127654
           Summary: Neg/BIT_NOT should be factored out even with constants
           Product: gcc
           Version: 17.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
            Blocks: 126043
  Target Milestone: ---

Take:
```
int test1 (int i, int j)
{
  if (i >= j) {
    return -(i != j);
  }
  return -1;
}
int test2 (int i, int j)
{
  if (i >= j) {
    return ~(i != j);
  }
  return ~1;
}
```

These two should produce either -(i != j) or ~(i != j) but neither does.

This is drived from tree-ssa/ssa-ifcombine-7.c after the patch for early phiopt
(PR 126043).


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126043
[Bug 126043] early phiopt should allow CMP, (cast)CMP, -(cast)CMP

Reply via email to