https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110289
--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
This patch fixes the problem
diff --git a/gcc/passes.def b/gcc/passes.def
index c9a8f19747b..faa5208b26b 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -88,6 +88,8 @@ along with GCC; see the file COPYING3. If not see
/* pass_build_ealias is a dummy pass that ensures that we
execute TODO_rebuild_alias at this point. */
NEXT_PASS (pass_build_ealias);
+ /* Do phiprop before FRE so we optimize std::min and std::max well.
*/
+ NEXT_PASS (pass_phiprop);
NEXT_PASS (pass_fre, true /* may_iterate */);
NEXT_PASS (pass_early_vrp);
NEXT_PASS (pass_merge_phi);
diff --git a/gcc/tree-ssa-phiprop.cc b/gcc/tree-ssa-phiprop.cc
index 3cb4900b6be..5dc505df420 100644
--- a/gcc/tree-ssa-phiprop.cc
+++ b/gcc/tree-ssa-phiprop.cc
@@ -476,6 +476,7 @@ public:
{}
/* opt_pass methods: */
+ opt_pass * clone () final override { return new pass_phiprop (m_ctxt); }
bool gate (function *) final override { return flag_tree_phiprop; }
unsigned int execute (function *) final override;
and helps PR110287