Proper VNs for zeroed structs (#61285)
authorSingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
Tue, 9 Nov 2021 19:12:49 +0000 (22:12 +0300)
committerGitHub <noreply@github.com>
Tue, 9 Nov 2021 19:12:49 +0000 (20:12 +0100)
commit8d93078afabcaddae4db9d9204f9b1ac679dacde
tree78721ae7054e000690abc63505040d4b4a78ba6f
parent9c37cdc559a141c92e20e123c9a594fed3692fec
Proper VNs for zeroed structs (#61285)

* Number zero-initialized struct properly

Previously, zero-initialized struct locals were given
a special $VNForZeroMap, which had the nice property
that VNForMapSelect($VNForZeroMap, Field) would always
return zero of the appropriate type. However, the fact
that this VN is not unique meant that it was dangerous
to propagate it, e. g. through copies, which was hidden
by the fact that ApplySelectorsTypeCheck's logic is very
conservative.

This change introduces a new VNFunc to represent zeroed
objects - VNF_ZeroObj, that takes a struct handle as its
argument and is thus free of the aforementioned problem and
can be propagated freely and not treated specially. It
also, of course, retains the ZeroMap's selection property.

There are almost no diffs for this change because of some
other deficiencies in assertion and copy propagation, they
are being/will be fixed separately.

* Fix VNZeroForType's handling of SIMD types

Previously this codepath was reachable, but did not matter as
the returned values were immediately discarded because of the
conservative logic in VNApplySelectorsTypeCheck. This is still
more or less the case, but let's just fix it properly.
src/coreclr/jit/compiler.h
src/coreclr/jit/ee_il_dll.hpp
src/coreclr/jit/valuenum.cpp
src/coreclr/jit/valuenum.h
src/coreclr/jit/valuenumfuncs.h