https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107505
Alexander Monakov <amonakov at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amonakov at gcc dot gnu.org --- Comment #1 from Alexander Monakov <amonakov at gcc dot gnu.org> --- Thanks. This is tree-ssa-sink relocating the call after 'zero' is discovered to be const, so I think the fix may be as simple as diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc index 921305201..631fc88c3 100644 --- a/gcc/tree-ssa-sink.cc +++ b/gcc/tree-ssa-sink.cc @@ -266,11 +266,11 @@ statement_sink_location (gimple *stmt, basic_block frombb, /* We only can sink assignments and non-looping const/pure calls. */ int cf; if (!is_gimple_assign (stmt) && (!is_gimple_call (stmt) || !((cf = gimple_call_flags (stmt)) & (ECF_CONST|ECF_PURE)) - || (cf & ECF_LOOPING_CONST_OR_PURE))) + || (cf & (ECF_LOOPING_CONST_OR_PURE|ECF_RETURNS_TWICE)))) return false; /* We only can sink stmts with a single definition. */ def_p = single_ssa_def_operand (stmt, SSA_OP_ALL_DEFS); if (def_p == NULL_DEF_OPERAND_P)