http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57361
Bug ID: 57361
Summary: Remove self memory assignment
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: glisse at gcc dot gnu.org
Hello,
as noticed in PR 57303, tree level optimizations don't remove self memory
assignments:
typedef struct A{long l,m,n,o,p;} A;
void f(A*x){
*x=*x;
}
compiled with -O3 still has the assignment in the .optimized dump.
I suggested removing statements where rhs is tcc_reference and
operand_equal_p(lhs,rhs), but Richard warns: "The obvious place would be dead
store elimination. But beware that the above, if not _literally_ being *p = *p
can be changing the effective type of the memory location and thus might be not
dead in terms of type-based aliasing rules (which basically means that we need
to do sth more clever than just removing the store)."