[store-merging] Use store order as tie-breaker in sort_by_bitpos
commitca4982c229fb010229e14478e45c86bd7e52cc97
authorktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Sep 2017 13:49:50 +0000 (13 13:49 +0000)
committerktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Sep 2017 13:49:50 +0000 (13 13:49 +0000)
tree13d7fed1d513aede40a8fcde7e9259c7feb77bbf
parentc53cd8cf0ea95284123ca6c08857b321d62313d8
[store-merging] Use store order as tie-breaker in sort_by_bitpos

As Alexander pointed out in the thread starting at [1] the sort_by_bitpos sorting function
was behaving badly when we had multiple stores at the same position.  He fixed that (thanks!)
but we can do better by not returning zero when the bitpositions are equal but by falling back
to comparing the order the stores appear in, which is guaranteed to be unique (barring other
bugs elsewhere).

This patch does that.

Bootstrapped and tested on aarch64-none-linux-gnu.

[1] https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00895.html

* gimple-ssa-store-merging.c (sort_by_bitpos): Compare store order
when bitposition is the same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@252084 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/gimple-ssa-store-merging.c