alias: Fix offset checks involving section anchors [PR92294]
memrefs_conflict_p assumes that:
[XB + XO, XB + XO + XS)
does not alias
[YB + YO, YB + YO + YS)
whenever:
[XO, XO + XS)
does not intersect
[YO, YO + YS)
In other words, the accesses can alias only if XB == YB at runtime.
However, this doesn't cope correctly with section anchors.
For example, if XB is an anchor symbol and YB is at offset
XO from the anchor, then:
[XB + XO, XB + XO + XS)
overlaps
[YB, YB + YS)
whatever the value of XO is. In other words, when doing the
alias check for two symbols whose local definitions are in
the same block, we should apply the known difference between
their block offsets to the intersection test above.
gcc/
PR rtl-optimization/92294
* alias.c (compare_base_symbol_refs): Take an extra parameter
and add the distance between two symbols to it. Enshrine in
comments that -1 means "either 0 or 1, but we can't tell
which at compile time".
(memrefs_conflict_p): Update call accordingly.
(rtx_equal_for_memref_p): Likewise. Take the distance between symbols
into account.