https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127052
Bug ID: 127052
Summary: cond_store_replacement_limited should support more
than ssa name stores
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: pinskia at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Currently it does:
```
rhs = gimple_assign_rhs1 (store_middle);
if ((!REFERENCE_CLASS_P (lhs)
&& !DECL_P (lhs))
|| !is_gimple_reg_type (TREE_TYPE (lhs)))
return false;
if (TREE_CODE (rhs) != SSA_NAME)
return false;
```
I think I was trying to reject constructors here.
Anyways simple testcase for -Ofast:
```
struct s1
{
int t;
s1 ();
};
struct s2 : s1
{
s2();
s2(int a);
};
s2::s2()
{
if (t)
t = 0;
}
s2::s2(int a)
{
if (t)
t = a;
}
```
phiopt1 can handle `= a` case but not `= 0` case.
I noticed this in std::optional::reset.