This fixes the -g variant of the original testcase.
PR tree-optimization/109410
* tree-ssa-reassoc.cc (build_and_add_sum): Use
gsi_start_nondebug_after_labels_bb to look for a possible
returns-twice call.
* gcc.dg/pr109410-2.c: New testcase.
--- /dev/null
+/* PR tree-optimization/109410 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+
+#include "pr109410.c"
if ((!op1def || gimple_nop_p (op1def))
&& (!op2def || gimple_nop_p (op2def)))
{
- gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
+ gsi = gsi_start_nondebug_after_labels_bb
+ (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
if (!gsi_end_p (gsi)
&& is_gimple_call (gsi_stmt (gsi))
&& (gimple_call_flags (gsi_stmt (gsi)) & ECF_RETURNS_TWICE))