tree-optimization/105562 - avoid uninit diagnostic with better FRE
authorRichard Biener <rguenther@suse.de>
Thu, 12 May 2022 10:13:29 +0000 (12:13 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 19 May 2022 11:59:30 +0000 (13:59 +0200)
commit844a5c8ca768dc0cc90c1a943756610832d686a8
treeed1d22179e3bbb80edb125c597514a1f946d819a
parent2a040e982945a5795081e81be35094b604d596d3
tree-optimization/105562 - avoid uninit diagnostic with better FRE

We can avoid some uninit diagnostics by making FRE disambiguate
against CLOBBERs since any aliasing there would invoke undefined
behavior for a read we are looking up.

2022-05-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105562
* tree-ssa-sccvn.cc (vn_reference_lookup_3): Disambiguate
against all CLOBBER defs if there's not an obvious must-alias
and we are not doing redundant store elimination.
(vn_walk_cb_data::redundant_store_removal_p): New field.
(vn_reference_lookup_pieces): Initialize it.
(vn_reference_lookup): Add argument to specify if we are
doing redundant store removal.
(eliminate_dom_walker::eliminate_stmt): Specify we do.
* tree-ssa-sccvn.h (vn_reference_lookup): Adjust.

* g++.dg/warn/uninit-pr105562.C: New testcase.

(cherry picked from commit 94b8a37fa16f7638cc1965718f4ec71719506743)
gcc/testsuite/g++.dg/warn/uninit-pr105562.C [new file with mode: 0644]
gcc/tree-ssa-sccvn.cc
gcc/tree-ssa-sccvn.h