public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/57361] New: Remove self memory assignment @ 2013-05-21 19:10 glisse at gcc dot gnu.org 2013-05-22 8:35 ` [Bug tree-optimization/57361] " rguenth at gcc dot gnu.org 2013-06-13 19:47 ` glisse at gcc dot gnu.org 0 siblings, 2 replies; 3+ messages in thread From: glisse at gcc dot gnu.org @ 2013-05-21 19:10 UTC (permalink / raw) To: gcc-bugs 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)." ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/57361] Remove self memory assignment 2013-05-21 19:10 [Bug tree-optimization/57361] New: Remove self memory assignment glisse at gcc dot gnu.org @ 2013-05-22 8:35 ` rguenth at gcc dot gnu.org 2013-06-13 19:47 ` glisse at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: rguenth at gcc dot gnu.org @ 2013-05-22 8:35 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57361 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2013-05-22 Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Assignment expansion makes this optimization: /* Optimize away no-op moves without side-effects. */ if (operand_equal_p (to, from, 0)) return; The operand_equal_p implementation looks safe at the moment (even in terms of type-based aliasing rules). I'd have done a more aggressive optimization in DSE, doing if (stmt_kills_ref_p (stmt, gimple_assign_rhs1 (stmt))) ... must be a self-assignment ... which would definitely need extra care for self-assignments that change the effective type of a memory location. Though I have a hard time creating a testcase that would exhibit sth like MEM[(struct X *)q_1] = MEM[(struct Y *)q_1]; which would change the dynamic type of *q_1 to X from Y. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/57361] Remove self memory assignment 2013-05-21 19:10 [Bug tree-optimization/57361] New: Remove self memory assignment glisse at gcc dot gnu.org 2013-05-22 8:35 ` [Bug tree-optimization/57361] " rguenth at gcc dot gnu.org @ 2013-06-13 19:47 ` glisse at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: glisse at gcc dot gnu.org @ 2013-06-13 19:47 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57361 --- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> --- I'll let Richard decide if this should stay open for the more aggressive optimization or not. r200034 | glisse | 2013-06-12 19:56:30 +0200 (Wed, 12 Jun 2013) | 10 lines 2013-06-12 Marc Glisse <marc.glisse@inria.fr> PR tree-optimization/57361 gcc/ * tree-ssa-dse.c (dse_possible_dead_store_p): Handle self-assignment. gcc/testsuite/ * gcc.dg/tree-ssa/pr57361.c: New file. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-06-13 19:47 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-05-21 19:10 [Bug tree-optimization/57361] New: Remove self memory assignment glisse at gcc dot gnu.org 2013-05-22 8:35 ` [Bug tree-optimization/57361] " rguenth at gcc dot gnu.org 2013-06-13 19:47 ` glisse at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).