tree-optimization/109342 - wrong code with edge equivalences in VN
authorRichard Biener <rguenther@suse.de>
Thu, 30 Mar 2023 09:32:19 +0000 (11:32 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 30 Mar 2023 11:02:19 +0000 (13:02 +0200)
commit1d0ba4467dd9cad11eb9ff547442e3ce6292b892
treedaf4e2e864fd771d9e662346334bdf1e4b1d370c
parentee6ae8cb4793041590b479346433ed786a86985d
tree-optimization/109342 - wrong code with edge equivalences in VN

The following testcase shows a problem in how we query valitity for
equivalences on edges when the edge is a backedge and thus refering
to a block thats later in the iteration order we use for VN.  That
causes the dominated_by_p_w_unex helper to look at edge executable
state that's not yet computed and thus still at optimistic not
executable state.

The following makes sure to use a plain dominance check in these cases.

PR tree-optimization/109342
* tree-ssa-sccvn.cc (vn_nary_op_get_predicated_value): New
overload for edge.  When that edge is a backedge use
dominated_by_p directly.

* g++.dg/torture/pr109342.C: New testcase.
gcc/testsuite/g++.dg/torture/pr109342.C [new file with mode: 0644]
gcc/tree-ssa-sccvn.cc