[llvm] [LAA] Consider unknown SCEVs defined in the loop as IndirectUnsafe. (PR #99239)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 09:05:30 PDT 2024
preames wrote:
> Yes, the issue in the `@B_indices_loaded_in_loop_A_stored` is limited to the accesses to object `%B` which is indexed by a value loaded on each iteration. Because the both load and store use the same address, the distance between them is 0 and at the moment we determine there's no dependence between them. There can be however, e.g. if the loaded index for 2 consecutive iterations is the same, the later iteration depends on the earlier one.
I think we may need a deeper change here. Consider the case where an index is not a unknown, but some complicated non-affine AddRec (or other complicated computable SCEV expression involving wrapping). Without proving that the expression can't produce the same value twice, don't we have the same basic problem?
Actually, given the reasoning above, wouldn't a simple (urem (%base,+,1), 2) be enough to hit this problem? How do we avoid miscompiling that case? Looking at the generated checks, it looks like we bail if we're not dealing with an AddRec. I do notice that we're not checking for NoSelfWrap which I think we probably need to when computing bounds.
p.s. I'm totally fine with this as a workaround. If you want to land this as a workaround, and then continue the discussion, I'm fine with that.
https://github.com/llvm/llvm-project/pull/99239
More information about the llvm-commits
mailing list