Fix wrong-code issue in VN
authorRichard Biener <rguenther@suse.de>
Fri, 17 Feb 2023 08:30:49 +0000 (09:30 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 17 Feb 2023 11:31:17 +0000 (12:31 +0100)
commit417e95263ca4d7a6623783ad664cf6305d8d3fad
tree8054a6626250780222aaa8094204fb0e4e766042
parentf978585c2939691176ad8d3fa9c2e4e91ed18bf4
Fix wrong-code issue in VN

The following fixes the wrong removed dead store discovered on the
PR108657 testcase when the reported DSE issue is not fixed.
The issue is we were using ssa_undefined_value_p on virtual operands
which returns a result based on the real definition of the definition
statement.  That doesn't make sense so this patch guards the calls
properly and makes sure nobody else does the same mistake.

* tree-ssa.cc (ssa_undefined_value_p): Assert we are not
called on virtual operands.
* tree-ssa-sccvn.cc (vn_phi_lookup): Guard
ssa_undefined_value_p calls.
(vn_phi_insert): Likewise.
(set_ssa_val_to): Likewise.
(visit_phi): Avoid extra work with equivalences for
virtual operand PHIs.
gcc/tree-ssa-sccvn.cc
gcc/tree-ssa.cc