From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7879) id 4827B385B516; Wed, 15 Feb 2023 10:25:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4827B385B516 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676456751; bh=MMNypH5Cx+TzwtF4uvG3Stn6Np2j94niv5DH0PuZg8w=; h=From:To:Subject:Date:From; b=mVFgFSFsD53eHUrVixyfhQNuPnonpFHzNpUBhCI1D1YNEwK1Jok6ZqtZ6gLp4x8vt kQ/2roLWPRtPiYDQptUuWDT94OOgrUHJiXWh0LBxD+kJ7n+0hYXsUo18xOYXpooGMR qZoeUNSZl85/Z/bKGDvyKyGPjC4qW9vuu77yHrDw= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Filip Kastl To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/pheeck/heads/sccp)] compiler crashes on 20090917-1.c X-Act-Checkin: gcc X-Git-Author: Filip Kastl X-Git-Refname: refs/users/pheeck/heads/sccp X-Git-Oldrev: c1c1164b43b69a3004d29ec68cfc5bb8749b3ef5 X-Git-Newrev: f412011b1a0d65a8e8523a56d8681243865ca0ed Message-Id: <20230215102551.4827B385B516@sourceware.org> Date: Wed, 15 Feb 2023 10:25:51 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f412011b1a0d65a8e8523a56d8681243865ca0ed commit f412011b1a0d65a8e8523a56d8681243865ca0ed Author: Filip Kastl Date: Tue Nov 29 09:17:54 2022 +0100 compiler crashes on 20090917-1.c Diff: --- gcc/sccp.cc | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/gcc/sccp.cc b/gcc/sccp.cc index 0f2f5cd61a3..c8c24fca2cf 100644 --- a/gcc/sccp.cc +++ b/gcc/sccp.cc @@ -69,7 +69,10 @@ static bool may_generate_useful_copy (gimple *stmt) { if (gimple_code (stmt) == GIMPLE_PHI) - return !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_phi_result (stmt)); + return true; + else + return false; + //return !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_phi_result (stmt)); // return true; // TODO if (gimple_code (stmt) != GIMPLE_ASSIGN) @@ -85,9 +88,11 @@ may_generate_useful_copy (gimple *stmt) return false; /* If the assignment is from a constant it generates a useful copy. */ + /* TODO if (gimple_assign_single_p (stmt) && is_gimple_min_invariant (gimple_assign_rhs1 (stmt))) return true; + */ /* Otherwise, the only statements that generate useful copies are assignments whose single SSA use doesn't flow through abnormal @@ -217,9 +222,7 @@ tarjan_compute_sccs (auto_vec ©_stmts) /* Iterate over neighbors of this vertex. */ ssa_op_iter iter; use_operand_p use_p; - std::cerr << gimple_code (stmt) << std::endl; // DEBUG - std::cerr << "Hi" << std::endl; - FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES) + FOR_EACH_PHI_OR_STMT_USE (use_p, stmt, iter, SSA_OP_ALL_USES) { tree op_var = USE_FROM_PTR (use_p); @@ -306,7 +309,7 @@ static void replace_scc_by_value (vec scc, tree replace_by) { // DEBUG - if (scc.length () >= 1) + if (scc.length () >= 5) { std::cerr << "Replacing SCC of length " << scc.length () << std::endl; } @@ -363,8 +366,9 @@ sccp_propagate (auto_vec ©_stmts) ssa_op_iter iter; use_operand_p use_p; - FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES) + FOR_EACH_PHI_OR_STMT_USE (use_p, stmt, iter, SSA_OP_ALL_USES) { + //std::cerr << "Argument" << std::endl; // DEBUG tree op_var = USE_FROM_PTR (use_p); bool op_in_scc = false; @@ -378,6 +382,7 @@ sccp_propagate (auto_vec ©_stmts) if (!op_in_scc) { outer_ops.add (op_var); + last_outer_op = op_var; is_inner = false; } } @@ -388,6 +393,14 @@ sccp_propagate (auto_vec ©_stmts) } } + // DEBUG + /* + for (gimple *s : scc) + { + debug_gimple_stmt (s); + } + */ + if (outer_ops.elements () == 1) { /* The only operand in outer_ops. */ @@ -430,14 +443,6 @@ get_all_may_generate_useful_copy (void) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple *s = gsi_stmt (gsi); - - /* - std::cerr << GIMPLE_PHI << std::endl; // DEBUG - std::cerr << GIMPLE_ASSIGN << std::endl; - debug_gimple_stmt (s); - std::cerr << gimple_code (s) << std::endl << std::endl; - */ - if (may_generate_useful_copy (s)) result.safe_push (s); } @@ -446,14 +451,6 @@ get_all_may_generate_useful_copy (void) for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi)) { gimple *s = pi.phi (); - - /* - std::cerr << GIMPLE_PHI << std::endl; // DEBUG - std::cerr << GIMPLE_ASSIGN << std::endl; - debug_gimple_stmt (s); - std::cerr << gimple_code (s) << std::endl << std::endl; - */ - if (may_generate_useful_copy (s)) result.safe_push (s); }