tree-optimization/102920 - fix PHI VN with undefined args
authorRichard Biener <rguenther@suse.de>
Mon, 25 Oct 2021 07:33:15 +0000 (09:33 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 25 Oct 2021 08:28:00 +0000 (10:28 +0200)
commitaa15952d646fd5dd569fce287b719a737ae66e4f
treef0b2f3add7c2e9297845e5b19a1dd971f4211791
parent7c20a9b738a2257bed4e2b0593275336d1e2047a
tree-optimization/102920 - fix PHI VN with undefined args

This fixes a latent issue exposed by now allowing VN_TOP in PHI
arguments.  We may only use optimistic equality when merging values on
different edges, not when merging values on the same edge - in particular
we may not choose the undef value on any edge when there's a not undef
value as well.

2021-10-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/102920
* tree-ssa-sccvn.h (expressions_equal_p): Add argument
controlling VN_TOP matching behavior.
* tree-ssa-sccvn.c (expressions_equal_p): Likewise.
(vn_phi_eq): Do not optimistically match VN_TOP.

* gcc.dg/torture/pr102920.c: New testcase.
gcc/testsuite/gcc.dg/torture/pr102920.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c
gcc/tree-ssa-sccvn.h