diff options
author | Andrew Pinski <apinski@marvell.com> | 2023-04-01 04:59:11 +0000 |
---|---|---|
committer | Andrew Pinski <apinski@marvell.com> | 2023-04-27 08:00:25 -0700 |
commit | 82f4f90a3761848ac71cee4fc607483572c0b34b (patch) | |
tree | 3ac8bf519ea8b3b1de7d0b6c1f746d30b105d2ac /gcc/tree-ssa-phiopt.cc | |
parent | 5fecfed8788eb114508e36e465147f2bb856fa33 (diff) | |
download | gcc-82f4f90a3761848ac71cee4fc607483572c0b34b.zip gcc-82f4f90a3761848ac71cee4fc607483572c0b34b.tar.gz gcc-82f4f90a3761848ac71cee4fc607483572c0b34b.tar.bz2 |
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.
Diffstat (limited to 'gcc/tree-ssa-phiopt.cc')
-rw-r--r-- | gcc/tree-ssa-phiopt.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 5ab23b5..7fc6ac1 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; |