https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104156
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:f953c8bc5bf314a57a6ba347ee6f5f5e3f1dad53 commit r12-6790-gf953c8bc5bf314a57a6ba347ee6f5f5e3f1dad53 Author: Richard Biener <rguent...@suse.de> Date: Fri Jan 21 10:19:58 2022 +0100 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 <rguent...@suse.de> PR tree-optimization/104156 * tree-ssa-loop-unswitch.cc (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.