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

            Bug ID: 122034
           Summary: __builtin_stack_save/__builtin_stack_restore pair is
                    not removed if there is no alloca inbetween
           Product: gcc
           Version: 16.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 g(int*);
int h(int,int);
double t;
double hh(double);
int f(int a, int b)
{
  {
  int array0[a];
  {
    int array1[b];
  }
  t = hh(t);
  }
  return h(a,b);
}
```

We end up with:
```
  saved_stack.6_5 = __builtin_stack_save ();
  saved_stack.4_8 = __builtin_stack_save ();
  __builtin_stack_restore (saved_stack.4_8);
  t.5_1 = t;
  _2 = hh (t.5_1);
  t = _2;
  __builtin_stack_restore (saved_stack.6_5);
```

But we should be able to remove the save/restore here too.

Reply via email to