tree-optimization/104156 - fix unswitching compare-debug issue
authorRichard Biener <rguenther@suse.de>
Fri, 21 Jan 2022 09:19:58 +0000 (10:19 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 21 Jan 2022 11:18:59 +0000 (12:18 +0100)
commitf953c8bc5bf314a57a6ba347ee6f5f5e3f1dad53
tree1cc019018d877b61e224cf210476570fc58de252
parent1ad72811242eb84dde1bb2e97d0804d6eabeac8a
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  <rguenther@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.
gcc/testsuite/gcc.dg/loop-unswitch-6.c [new file with mode: 0644]
gcc/tree-ssa-loop-unswitch.cc