aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-phiopt.c
diff options
context:
space:
mode:
authorJoern Rennecke <joern.rennecke@riscy-ip.com>2019-07-01 21:48:55 +0000
committerJoern Rennecke <amylaar@gcc.gnu.org>2019-07-01 22:48:55 +0100
commit5cc8cb04de4285bfa85c16073e99185b41c38f85 (patch)
tree351370b02de7ff80f730e5838e84ab8722d05fca /gcc/tree-ssa-phiopt.c
parent63c94f4cb0cffa6f3b316d4631092afee734506f (diff)
downloadgcc-5cc8cb04de4285bfa85c16073e99185b41c38f85.zip
gcc-5cc8cb04de4285bfa85c16073e99185b41c38f85.tar.gz
gcc-5cc8cb04de4285bfa85c16073e99185b41c38f85.tar.bz2
re PR tree-optimization/66726 (missed optimization, factor conversion out of COND_EXPR)
PR middle-end/66726 * tree-ssa-phiopt.c (factor_out_conditional_conversion): Tune heuristic from PR71016 to allow MIN / MAX. * testsuite/gcc.dg/tree-ssa/pr66726-4.c: New testcase. From-SVN: r272911
Diffstat (limited to 'gcc/tree-ssa-phiopt.c')
-rw-r--r--gcc/tree-ssa-phiopt.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 90674a2..7088ff9 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -504,7 +504,24 @@ factor_out_conditional_conversion (edge e0, edge e1, gphi *phi,
gsi = gsi_for_stmt (arg0_def_stmt);
gsi_prev_nondebug (&gsi);
if (!gsi_end_p (gsi))
- return NULL;
+ {
+ if (gassign *assign
+ = dyn_cast <gassign *> (gsi_stmt (gsi)))
+ {
+ tree lhs = gimple_assign_lhs (assign);
+ enum tree_code ass_code
+ = gimple_assign_rhs_code (assign);
+ if (ass_code != MAX_EXPR && ass_code != MIN_EXPR)
+ return NULL;
+ if (lhs != gimple_assign_rhs1 (arg0_def_stmt))
+ return NULL;
+ gsi_prev_nondebug (&gsi);
+ if (!gsi_end_p (gsi))
+ return NULL;
+ }
+ else
+ return NULL;
+ }
gsi = gsi_for_stmt (arg0_def_stmt);
gsi_next_nondebug (&gsi);
if (!gsi_end_p (gsi))