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

            Bug ID: 122273
           Summary: cselim-limited does not handle some cases where the
                    aliasing seems the same
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
#include <new>

struct s1
{
  bool t;
  s1 (bool tt) {t = tt;}
  void set(bool tt) { t = tt;}
};

s1 *f(s1 *a, bool b)
{
  if (b)
  {
    a = new(a) s1(1);
  }
  else
  {
    a = new(a) s1(0);
  }
  return a;
}
```

For some reason the MEM_REF here is rejected. 

I have not looked into why cond_if_else_store_replacement_1 rejects this case.
Or why using {1}/{0} and removing the ctor allows
cond_if_else_store_replacement_1 to work too.

Reply via email to