This is a fix for PR57025 and an alternative to D131776. The problem in the memdep-unknown-deadblocks.ll test case is that phi translation of gep %arr, %j into store.done looks for a GEP of the form gep %arr, %i and picks the one in the store.idx.i block. While this instruction has the correct pointer address, it occurs in a context where %i != 0. As such, we get a NoAlias result for the store in store.idx.0 block, even though they do alias for %i == 0 (which is legal in the original context of the pointer).
PHITranslateValue already has a MustDominate option, which can be used to restrict PHI translation results to values that dominate the translated-into block. However, this is more aggressive than what we need and would significantly regress GVN results. In particular, if we have a pointer value that does not require any translation, then it is fine to continue using that value in the predecessor, because the context is still correct for the original query. We only run into problems if PHITranslateSubExpr() picks a completely random instruction in a context that may have preconditions that do not hold.
Fix this by always performing the dominance checks in PHITranslateSubExpr(), without enabling the more general MustDominate requirement.
Fixes https://github.com/llvm/llvm-project/issues/57025. This also fixes the test case for https://github.com/llvm/llvm-project/issues/30999, but I'm not sure whether that's just the particular test case, or a general solution to the problem.
Depends on D131775.