https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116906
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:9ade99bfbc7f47975d7f8765366904f4d2496afc commit r13-9513-g9ade99bfbc7f47975d7f8765366904f4d2496afc Author: Richard Biener <rguent...@suse.de> Date: Tue Oct 1 10:37:16 2024 +0200 tree-optimization/116906 - unsafe PRE with never executed edges When we're computing ANTIC for PRE we treat edges to not yet visited blocks as having a maximum ANTIC solution to get at an optimistic solution in the iteration. That assumes the edges visted eventually execute. This is a wrong assumption that can lead to wrong code (and not only non-optimality) when possibly trapping expressions are involved as the testcases in the PR show. The following mitigates this by pruning trapping expressions from ANTIC computed when maximum sets are involved. PR tree-optimization/116906 * tree-ssa-pre.cc (prune_clobbered_mems): Add clean_traps argument. (compute_antic_aux): Direct prune_clobbered_mems to prune all traps when any MAX solution was involved in the ANTIC computation. (compute_partial_antic_aux): Adjust. * gcc.dg/pr116906-1.c: New testcase. * gcc.dg/pr116906-2.c: Likewise. (cherry picked from commit 3e1bd6470e4deba1a3ad14621037098311ad1350)