Fix selection of references for graph layout.

Don't remove references that refer to the same element of the same array - only remove references when another reference refers to an element with a lower index in the same array.

Never remove all references in reduceReferences().

Don't directly compare types in doReferenceSameValue(), because the pointers might come from different translation units. Also, directly calculate the expected offset of the matching dereference rather than iterating until we find it.