I can see below output from alias set tracker for above code snippet.
Alias sets for function 'test':
Alias Set Tracker: 1 alias sets for 2 pointer values.
AliasSet[0x53d8070, 2] may alias, Mod Pointers: (i8* %arrayidx, 1), (i8* %arrayidx2, 1)
As you can see on above code snippet, the 'a' and 'b' are not aliased. I think if we have following offset form, we can say No-alias between them.
offset1 = odd_number - index
offset2 = index
I have implemented simple code for it and the output is as following:
Alias sets for function 'test':
Alias Set Tracker: 2 alias sets for 2 pointer values.
AliasSet[0x541a070, 1] must alias, Mod Pointers: (i8* %arrayidx, 1)
AliasSet[0x541cc00, 1] must alias, Mod Pointers: (i8* %arrayidx2, 1)
How do you think about this? Is it legal for current alias analysis or not? I have attached the diff file as reference. If I missed something, please let me know.
The concept works. I'm not sure your patch handles all the edge cases correctly, at first glance. (If you want a full review, please post on Phabricator.)
I can see below output from alias set tracker for above code snippet.
Alias sets for function 'test':
Alias Set Tracker: 1 alias sets for 2 pointer values.
AliasSet[0x53d8070, 2] may alias, Mod Pointers: (i8*
%arrayidx, 1), (i8* %arrayidx2, 1)
As you can see on above code snippet, the 'a' and 'b' are not
aliased. I think if we have following offset form, we can say
No-alias between them.
offset1 = odd_number - index
offset2 = index
I have implemented simple code for it and the output is as following:
Alias sets for function 'test':
Alias Set Tracker: 2 alias sets for 2 pointer values.
AliasSet[0x541a070, 1] must alias, Mod Pointers: (i8*
%arrayidx, 1)
AliasSet[0x541cc00, 1] must alias, Mod Pointers: (i8*
%arrayidx2, 1)
How do you think about this? Is it legal for current alias analysis
or not? I have attached the diff file as reference. If I missed
something, please let me know.
The concept works. I'm not sure your patch handles all the edge cases
correctly, at first glance. (If you want a full review, please post
on Phabricator.)
+1
In your example, we have:
3 - idx == idx => 3 == 2*idx
and you've generalized this slightly to make this:
(odd number) == 2*idx
which makes sense. I think that we can go further looking at:
n == 2*idx
and, calling computeKnownBits on n and idx, then asking whether:
Sadly, we don't have a good API to do the knownBits check on the
subtraction of non-constants, but you only need the constants in your
case, and we can leave the more-general case for future work.