I’ve been surprised by how “over the top” the set of opts in DAGCombiner are,
But here’s one that might be missing
Array[ I + (pointer-difference) ]
Generates … (shl (sra (sub pointer1, pointer2), 2), 2) …
Which gets Combined into
(and (sub pointer1, pointer2), -4)
But IIUC the C/C++ languages require pointer1 and pointer2 to be addresses of elements in the same array,
So their difference must be (0 mod element-size),
(even if the array itself is somehow misaligned, the difference between elements will be aligned)
so the “SRA” is only shifting out zeros,
So the “AND” by “-4” is superfluous
Please let me know if I am misunderstanding something ?!
–Peter Lawrence.