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
If running opt -passes='aa-eval' -print-all-alias-modref-info we see that %gep and %gep2 id detected as "MayAlias".
(This also happens if replacing the "or disjoint" by "add nsw nuw".)
I did try to manually rewrite the IR a bit. Given that a>=0 and nr>0 I think we can rewrite
; mul2 = (a + 1) * nr
%or = or disjoint i16 %a, 1
%mul2 = mul nsw nuw i16 %or, %nr
as
; mul2 = (a * nr) + nr
%mul = mul nsw nuw i16 %a, %nr
%mul2 = add nsw nuw i16 %mul, %nr
And then it looks like we would derive "NoAlias" when the IR looks like this instead:
Given that it is possible to derive NoAlias for @foo above then I think it should be possible for @bar as well. And if that is solved I guess we would be able to see that the stores in the @csource test case as well.
It is at least a bit unfortunate that the C code is lowered into IR that doesn't satisfy alias analysis in the sense that we can derive that the stores are safe to reorder (or execute in parallel). Btw, if unrolling the loop we do get 64 pointers that has NoAlias, so there isn't even aliasing between iterations.
PS. Context for this problem is that I've been analysing downstream regressions after #119365 . This might be one part of the puzzle, but real problem seem to be that we drop knowledge about "nsw" after LoopStrenghtReduce. I suspect that if we can't derive NoAlias before loop-reduce, then it is even harder for loop-reduce/scev-expander to reason about "nsw" when generating reassociations.
The text was updated successfully, but these errors were encountered:
Consider this IR:
If running
opt -passes='aa-eval' -print-all-alias-modref-info
we see that %gep and %gep2 id detected as "MayAlias".(This also happens if replacing the "or disjoint" by "add nsw nuw".)
I did try to manually rewrite the IR a bit. Given that a>=0 and nr>0 I think we can rewrite
as
And then it looks like we would derive "NoAlias" when the IR looks like this instead:
So there seems to be a bit of inconsistency in the analysis, making it sensitive to what the IR looks like.
Here is a C level reproducer:
Compiled with
-emit-llvm -O3 -g0
we get IR similar to @bar above:Which according to aa-eval is identified as:
Given that it is possible to derive NoAlias for
@foo
above then I think it should be possible for@bar
as well. And if that is solved I guess we would be able to see that the stores in the@csource
test case as well.It is at least a bit unfortunate that the C code is lowered into IR that doesn't satisfy alias analysis in the sense that we can derive that the stores are safe to reorder (or execute in parallel). Btw, if unrolling the loop we do get 64 pointers that has NoAlias, so there isn't even aliasing between iterations.
PS. Context for this problem is that I've been analysing downstream regressions after #119365 . This might be one part of the puzzle, but real problem seem to be that we drop knowledge about "nsw" after LoopStrenghtReduce. I suspect that if we can't derive NoAlias before loop-reduce, then it is even harder for loop-reduce/scev-expander to reason about "nsw" when generating reassociations.
The text was updated successfully, but these errors were encountered: