Credit to @bjope for debugging this.
I've no idea if the fix itself makes sense but at least it does seem to fix my reproducer for PR38513 and I didn't see any problems with the patch during the (limited) testing I've done.
Add a few CHECKs here perhaps?
error: no check strings found with prefix 'CHECK:'
Nit: Wouldn't mind if we added a printout here to indicate when we have the AliasAny set (as that was helpful when debugging). I used something like this:
if (AliasAnyAS) OS << "Saturated!\n";
It is recommended to use redirect for the input to opt (https://llvm.org/docs/TestingGuide.html#fragile-tests):
; RUN: opt < %s -enable-mssa-loop-dependency=false -disable-basicaa -alias-set-saturation-threshold=2 -licm -S | FileCheck %s
Yes, CHECK:s are needed. And then "REQUIRES: asserts" can be removed.