You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which is wrong, because for even values of i, ptr2[i-1] reads the value written in the previous iteration. That is, there is a flow dependence.
The result is none because AliasAnalysis returns NoAlias for %ptr1 and %ptr2, which is correct in the sense that in the same iteration, one of them points to %A (which is noalias) and the other to %B (which is also noalias), ie. those two never alias.
DependenceAnalysis analyses dependencies across iterations and therefore will compare memory accesses from different iterations. I.e. %ptr1 is equal to %ptr2 from the previous iteration.
I think the problem here is that DependenceAnalysis makes two wrong assumptions that combined leads to wrongs results:
AliasAnalysis's results are valid across phi nodes
The base pointer is invariant in all loops
DependenceAnalysis on bar seems pessimistically correct, on xyzzy the correct flow/anti dependences are detected.
The text was updated successfully, but these errors were encountered:
It discusses extending the query interface for AliasAnalysis. However, I think it is more fundamental to check the loop-invariances of the base pointer. If base pointers varies between iterations, a DependencyAnalysis only taking subscripts into account cannot be correct. An extended cross-iteration AliasAnalysis could never return MustAlias in this case anyway, since the pointer will have different values in different iterations and only at most one of those could be MustAlias with another pointer (constant or the specific value of another varying pointer).
sebpop
added a commit
to sebpop/llvm-project
that referenced
this issue
Oct 18, 2024
Use the Memory SSA representation to check whether the base address of two
memory accesses are defined by a same memory SSA node.
This fixesllvm#41488
"Aliasing checks in DA are incorrect", and fixes the first testcase in
llvm#53942
"[DependenceAnalysis] assumes base pointer invariance".
This patch depends on a series of patches to preserve MemorySSA in the passes
that require array dependence analysis. For instance, loop-fuse fails 2 tests
in test/Transforms/LoopFusion because the transform invalidates the MemorySSA.
Consider these 3 functionally equivalent functions:
Compile with:
The
-da
result forfoo
is:which is wrong, because for even values of
i
,ptr2[i-1]
reads the value written in the previous iteration. That is, there is a flow dependence.The result is
none
because AliasAnalysis returns NoAlias for %ptr1 and %ptr2, which is correct in the sense that in the same iteration, one of them points to %A (which is noalias) and the other to %B (which is also noalias), ie. those two never alias.DependenceAnalysis analyses dependencies across iterations and therefore will compare memory accesses from different iterations. I.e. %ptr1 is equal to %ptr2 from the previous iteration.
I think the problem here is that DependenceAnalysis makes two wrong assumptions that combined leads to wrongs results:
DependenceAnalysis on
bar
seems pessimistically correct, onxyzzy
the correct flow/anti dependences are detected.The text was updated successfully, but these errors were encountered: