https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116906
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:fbecb7df9742ade5513d901ca03e9a6c082915e5 commit r14-11331-gfbecb7df9742ade5513d901ca03e9a6c082915e5 Author: Richard Biener <[email protected]> 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)
