tree-optimization/104156 - fix unswitching compare-debug issue

When hoisting guards the unswitching pass does not properly ignore
debug stmts when looking for uses outside of the loop of defs
produced in the skipped region.  The following rectifies this
by instead collecting them and resetting them after the transform.

2022-01-21  Richard Biener  <>

	PR tree-optimization/104156
	* (tree_unswitch_outer_loop):
	Collect and reset debug stmts with out-of-loop uses when
	hoisting guards.
	(find_loop_guard): Adjust.
	(empty_bb_without_guard_p): Likewise.  Ignore debug stmts.
	(used_outside_loop_p): Push debug uses to a vector of
	debug stmts to reset.
	(hoist_guard): Adjust -fopt-info category.

	* gcc.dg/loop-unswitch-6.c: New testcase.
2 files changed