This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Remove self-assignments
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 9 Jun 2013 18:25:46 +0200 (CEST)
- Subject: Remove self-assignments
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.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.
--
Marc Glisse
Index: testsuite/gcc.dg/tree-ssa/pr57361.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/pr57361.c (revision 0)
+++ testsuite/gcc.dg/tree-ssa/pr57361.c (revision 0)
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-dse1-details" } */
+
+struct A { int x; double y; };
+void f (struct A *a) {
+ *a = *a;
+}
+
+/* { dg-final { scan-tree-dump "Deleted dead store" "dse1"} } */
Property changes on: testsuite/gcc.dg/tree-ssa/pr57361.c
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision URL
Added: svn:eol-style
+ native
Index: tree-ssa-dse.c
===================================================================
--- tree-ssa-dse.c (revision 199867)
+++ tree-ssa-dse.c (working copy)
@@ -77,20 +77,29 @@ static void dse_enter_block (struct dom_
Return TRUE if the above conditions are met, otherwise FALSE. */
static bool
dse_possible_dead_store_p (gimple stmt, gimple *use_stmt)
{
gimple temp;
unsigned cnt = 0;
*use_stmt = NULL;
+ /* Self-assignments are zombies. */
+ if (gimple_assign_rhs_code (stmt) == TREE_CODE (gimple_assign_lhs (stmt))
+ && operand_equal_p (gimple_assign_rhs1 (stmt),
+ gimple_assign_lhs (stmt), 0))
+ {
+ *use_stmt = stmt;
+ return true;
+ }
+
/* Find the first dominated statement that clobbers (part of) the
memory stmt stores to with no intermediate statement that may use
part of the memory stmt stores. That is, find a store that may
prove stmt to be a dead store. */
temp = stmt;
do
{
gimple use_stmt, defvar_def;
imm_use_iterator ui;
bool fail = false;