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

            Bug ID: 119686
           Summary: strlen pass gets confused sometimes with stores
                    beforehand
           Product: gcc
           Version: 15.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 (taken from strlenopt-69.c):
```
extern char a4[4];
extern char b4[4];
void clobber (void*, ...);

void test_empty_string (void)
{
  *a4 = '\0';
  clobber (a4, b4);
  *a4 = 0;
  *b4 = 0;
  if (0 != __builtin_strcmp (a4, b4))
    __builtin_abort();
}
```

The strcmp should be optimized away to 0 because the strlen of both a4 and b4
are 0.

If you remove the store to a4[0] at the begining of the function, strlen pass
works.

Reply via email to