From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1314) id 375A33858D1E; Mon, 24 Apr 2023 15:50:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 375A33858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682351426; bh=jgAdbudlqMlXE0Gc4kzzQUCov45MadvhZ9P0m7PeVQY=; h=From:To:Subject:Date:From; b=xDjEGkgFcD2OqrCh2G/uwajZF3MnhHpOrk1TukZjtlO3omuTUdnZ7WqvZ2NOxKOQL og/oJ0zF0KpJUon38eRJVwo0BlklbEZK47uUB4oWBdLeC3U0whDm0AkjPy3eI4voCp 1bit+SjBlRNF7/68BkFScmKzeN4IlL0Y4317u+VE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Pinski To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-199] PHIOPT: Move check on diamond bb to tree_ssa_phiopt_worker from minmax_replacement X-Act-Checkin: gcc X-Git-Author: Andrew Pinski X-Git-Refname: refs/heads/trunk X-Git-Oldrev: b9ee7c6bfdbfcc722f3e4c8bd8378cccd4311740 X-Git-Newrev: 2f58dd71d1b8e23f28a43360742519e92ee0c8d5 Message-Id: <20230424155026.375A33858D1E@sourceware.org> Date: Mon, 24 Apr 2023 15:50:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:2f58dd71d1b8e23f28a43360742519e92ee0c8d5 commit r14-199-g2f58dd71d1b8e23f28a43360742519e92ee0c8d5 Author: Andrew Pinski Date: Thu Apr 20 09:23:25 2023 -0700 PHIOPT: Move check on diamond bb to tree_ssa_phiopt_worker from minmax_replacement This moves the check to make sure on the diamond shaped form bbs that the the two middle bbs are only for that diamond shaped form earlier in the shared code. Also remove the redundant check for single_succ_p since that was already done before hand. The next patch will simplify the code even further and remove redundant checks. PR tree-optimization/109604 gcc/ChangeLog: * tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Move the diamond form check from ... (minmax_replacement): Here. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr109604-1.c: New test. * gcc.c-torture/compile/pr109604-2.c: New test. Diff: --- gcc/testsuite/gcc.c-torture/compile/pr109604-1.c | 13 +++++++++++++ gcc/testsuite/gcc.c-torture/compile/pr109604-2.c | 13 +++++++++++++ gcc/tree-ssa-phiopt.cc | 14 ++++++++------ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/gcc/testsuite/gcc.c-torture/compile/pr109604-1.c b/gcc/testsuite/gcc.c-torture/compile/pr109604-1.c new file mode 100644 index 00000000000..4374f0e068b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr109604-1.c @@ -0,0 +1,13 @@ +/* This used to ICE after PHI-OPT because of the "empty block" and diamond form bbs + was not checking to make sure each bbs were only coming from the one bb. */ + +int nilfs_bmap_find_target_seq_bmap; +unsigned long nilfs_bmap_find_target_seq_bmap_0; +unsigned long nilfs_bmap_find_target_seq() { + if (nilfs_bmap_find_target_seq_bmap && + nilfs_bmap_find_target_seq_bmap_0 + nilfs_bmap_find_target_seq_bmap) + return nilfs_bmap_find_target_seq_bmap_0 + nilfs_bmap_find_target_seq_bmap; + else + return 0; +} + diff --git a/gcc/testsuite/gcc.c-torture/compile/pr109604-2.c b/gcc/testsuite/gcc.c-torture/compile/pr109604-2.c new file mode 100644 index 00000000000..29db0b5c245 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr109604-2.c @@ -0,0 +1,13 @@ +/* This used to ICE after PHI-OPT because of the "empty block" and diamond form bbs + was not checking to make sure each bbs were only coming from the one bb. */ + +struct { + int second; +} selectPlayer_playerRes; +int selectPlayer_playerRes_0; +int selectPlayer() { + if (selectPlayer_playerRes_0 && selectPlayer_playerRes.second >= 0) + return selectPlayer_playerRes.second; + else + return -1; +} diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 14e689bf484..c94aadbce8d 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -218,6 +218,14 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p) continue; } + if (diamond_p) + { + if (!single_pred_p (bb1) + || !single_pred_p (bb2) + || !single_succ_p (bb2)) + continue; + } + if (do_store_elim && !diamond_p) { /* Also make sure that bb1 only have one predecessor and that it @@ -2029,12 +2037,6 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb, basic_block alt_ tree alt_lhs, alt_op0, alt_op1; bool invert = false; - if (!single_pred_p (middle_bb) - || !single_pred_p (alt_middle_bb) - || !single_succ_p (middle_bb) - || !single_succ_p (alt_middle_bb)) - return false; - /* When THREEWAY_P then e1 will point to the edge of the final transition from middle-bb to end. */ if (true_edge == e0)