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

            Bug ID: 122830
           Summary: Another missing VN via a struct copy
           Product: gcc
           Version: 16.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: 122824
  Target Milestone: ---

Take:
```
struct s1
{
  int c;
};
struct s2
{
  struct s1 l;
};

void f(int fill)
{
  s1 D144916, last;
  int a = fill;
  D144916.c = a;
  s2 D135323;
  D135323.l = D144916;
  struct s1 *s = &D135323.l;
  const int *sc = &s->c;
  if (*sc != a)
    __builtin_abort();
}
```

Compile with `-O2 -fno-tree-sra` and see that fre1 does not optimize away the
condition.

This is the reduced testcase from PR 122824 which is causing a warning for out
of bounds code to happen for code will never execute.
Since SRA is after fre3 and after the out of bounds warnings, the above code is
trying to simulate that for the pre-inline optimizations with the addition of
-no-tree-sra.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122824
[Bug 122824] Array out-of-bounds warning when building with optimization
greater than -O1

Reply via email to