]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/116906 - unsafe PRE with never executed edges
authorRichard Biener <rguenther@suse.de>
Tue, 1 Oct 2024 08:37:16 +0000 (10:37 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 1 Oct 2024 09:44:50 +0000 (11:44 +0200)
commit3e1bd6470e4deba1a3ad14621037098311ad1350
tree3abc8e1f801ffce0d0ddb3d5ad3c636f133f3511
parentde25f1729d212c11d6e2955130f4eb1d272b5ce7
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.
gcc/testsuite/gcc.dg/pr116906-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr116906-2.c [new file with mode: 0644]
gcc/tree-ssa-pre.cc