From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1314) id B8FE63857739; Thu, 27 Apr 2023 15:01:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8FE63857739 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682607674; bh=rmFg2P6i5r0hSQAQ67g3QeLZFsf8YE7aH/ge66ds3f8=; h=From:To:Subject:Date:From; b=rjhvWyyysvxXqxRnxkyHxOtd56UW/14CIKCq1Ua9hrT264VranxHNlUTyl7igB5/c 1l1WaOcjZBIT/NyJDZZQt7gmDb2I/s5MnobCk7W++rjasLnG6q2niRGJmVfmkVyej4 LzYHUIivLv7K3Mydt4ojKfWOGzhir0Ke32tuU8B8= 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-307] PHIOPT: Allow MIN/MAX to have up to 2 MIN/MAX expressions for early phiopt X-Act-Checkin: gcc X-Git-Author: Andrew Pinski X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 5fecfed8788eb114508e36e465147f2bb856fa33 X-Git-Newrev: 82f4f90a3761848ac71cee4fc607483572c0b34b Message-Id: <20230427150114.B8FE63857739@sourceware.org> Date: Thu, 27 Apr 2023 15:01:14 +0000 (GMT) List-Id: https://gcc.gnu.org/g:82f4f90a3761848ac71cee4fc607483572c0b34b commit r14-307-g82f4f90a3761848ac71cee4fc607483572c0b34b Author: Andrew Pinski Date: Sat Apr 1 04:59:11 2023 +0000 PHIOPT: Allow MIN/MAX to have up to 2 MIN/MAX expressions for early phiopt In the early PHIOPT mode, the original minmax_replacement, would replace a PHI node with up to 2 min/max expressions in some cases, this allows for that too. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (phiopt_early_allow): Allow for up to 2 min/max expressions in the sequence/match code. Diff: --- gcc/tree-ssa-phiopt.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 5ab23b54ed6..7fc6ac17b4a 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -533,9 +533,23 @@ phiopt_early_allow (gimple_seq &seq, gimple_match_op &op) return false; tree_code code = (tree_code)op.code; - /* For non-empty sequence, only allow one statement. */ + /* For non-empty sequence, only allow one statement + except for MIN/MAX, allow max 2 statements, + each with MIN/MAX. */ if (!gimple_seq_empty_p (seq)) { + if (code == MIN_EXPR || code == MAX_EXPR) + { + if (!gimple_seq_singleton_p (seq)) + return false; + + gimple *stmt = gimple_seq_first_stmt (seq); + /* Only allow assignments. */ + if (!is_gimple_assign (stmt)) + return false; + code = gimple_assign_rhs_code (stmt); + return code == MIN_EXPR || code == MAX_EXPR; + } /* Check to make sure op was already a SSA_NAME. */ if (code != SSA_NAME) return false;