On Tue, 11 Jun 2013, Jeff Law wrote:
On 06/09/13 10:25, Marc Glisse wrote:
Hello,
this patch removes some self-assignments. I don't know if this is the
best way, but it passes a bootstrap and the testsuite on x86_64-linux-gnu.
2013-06-10 Marc Glisse <marc.gli...@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.
So dse_optimize_stmt will verify the statement does not have volatile
operands.
operand_equal_p also does it, so we are well covered there ;-)
However, it doesn't verify the statement does not potentially
throw (think about a segfault on the store when async exceptions are
enabled). I think you need to test for that explicitly.
Hmm, I am not at all familiar with that. Google drowns me in C# and
javascript links, and grepping through the sources only pointed me to the
-fasynchronous-unwind-tables flag.
Richard noticed in the PR that expand_assignment already does:
/* Optimize away no-op moves without side-effects. */
if (operand_equal_p (to, from, 0))
return;
so it looks like the operand_equal_p test should be sufficient (or the
compiler already breaks that code).
Is there some reason this won't work in tree-ssa-dce.c? That gets run more
often and these stores may be preventing code motion opportunities, so
getting them out of the IL stream as early as possible would be good.
In the first version of the patch:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57303#c6
I was doing it in fold_stmt_1, which should be called often enough.
Richard suggested DSE in the PR, but that might be because he had a more
subtle test in mind. I am certainly ok with moving it to DCE or anywhere
else...
I'd be curious how often this triggers in GCC itself as well.
Do you know a convenient way to test that?
--
Marc Glisse