From 4a87605938428f6c4c62d5b92cfc183cd2b2554e Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 1 Jul 2021 11:16:01 +0200 Subject: tree-optimization/101278 - handle self-use in DSE analysis DSE store classification short-cuts the to-be classified stmt itself from chaining but fails to first check whether the store uses itself which can be the case when it is a call with the LHS also passed by value as argument. 2021-07-01 Richard Biener PR tree-optimization/101278 * tree-ssa-dse.c (dse_classify_store): First check for uses, then ignore stmt for chaining purposes. * gcc.dg/torture/pr101278.c: New testcase. --- gcc/tree-ssa-dse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gcc/tree-ssa-dse.c') diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index c3939a6..98daa8a 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -813,15 +813,11 @@ dse_classify_store (ao_ref *ref, gimple *stmt, break; } - /* We have visited ourselves already so ignore STMT for the - purpose of chaining. */ - if (use_stmt == stmt) - ; /* In simple cases we can look through PHI nodes, but we have to be careful with loops and with memory references containing operands that are also operands of PHI nodes. See gcc.c-torture/execute/20051110-*.c. */ - else if (gimple_code (use_stmt) == GIMPLE_PHI) + if (gimple_code (use_stmt) == GIMPLE_PHI) { /* If we already visited this PHI ignore it for further processing. */ @@ -861,6 +857,10 @@ dse_classify_store (ao_ref *ref, gimple *stmt, fail = true; break; } + /* We have visited ourselves already so ignore STMT for the + purpose of chaining. */ + else if (use_stmt == stmt) + ; /* If this is a store, remember it as we possibly need to walk the defs uses. */ else if (gimple_vdef (use_stmt)) -- cgit v1.1