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

            Bug ID: 118254
           Summary: missed knowing lower bits of a variable when using
                    comparison of shorter type
           Product: gcc
           Version: 14.2.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
            Blocks: 85316
  Target Milestone: ---

Take:
```

void foo(void);
int il=1000;

int main(void)
{
  short t = il;
  unsigned t1 = t;
  if (t1 == 0) {
#if 1
    char b = t1;
#else
    char b = il;
#endif
    if (b != 1) __builtin_unreachable();
    foo();
  }
}
```

The call to foo should be optimized away since `b` is never 1. as il&0xffff and
therefor b is always 0.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases

Reply via email to