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

            Bug ID: 112390
           Summary: `!(A & INT_MIN) & !!(A & INT_MAX)` is not optimized to
                    `A > 0`
           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: ---

Take:
```
void fn();

void test(unsigned *d) {
    int is_negative = *d & 0x80000000;

    if (!is_negative & !!(*d & 0x7fffffff)) {
        fn();
    }
}

void test1(unsigned *d) {
    int is_negative = *d & 0x80000000;

    if (!is_negative && !!(*d & 0x7fffffff)) {
        fn();
    }
}
```

We are able to optimize test1 but not test at -O2. In this case we would need
some pattern matching I think.

Reply via email to