https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128638

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we can't possibly rely on seeing all expressions for a (partial) ANTIC value
for correctness.  With value-based PRE one could argue we may not unify two
expressions with different TBAA behavior to a single value.  For partial-PRE
the data flow problem speculates loads so it appears that may not use TBAA.

So to sum up, there's a disconnect between GVN-PRE that we attempt to implement
and the actual implementation:

GVN-PRE assumes value classes are context-free: any expression `e` in the
class of value V, phi-translated to a predecessor, yields V on **every**
path where V is computed, not only where `e` itself executes.

GCC's reference VN merges references whose results coincide at a memory
state; `tree-ssa-sccvn.cc` even states "Both alignment and alias set are
not relevant for the produced value". That holds for FRE, which only
reuses an executed, dominating access. But PRE's phi-translation re-walks
with the expression's own access facts — alias set / base set,
access-path disambiguation, size/alignment for trapping — which are only
valid (by the UB argument) on paths where that very access executes.

Required invariant: translating V through `e` is valid only if `e`'s
access facts are implied by **all statements carrying V in the function**,
not by the subset of expressions present in some PRE set.

We can either A) dump down the VN done for PRE; B) more whack-a-mole, we need
to cobble up all facts in compute_avail as from there information is lost

Reply via email to