This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 3/6] lra-assigns.c: fix pseudo_compare_func
- From: Alexander Monakov <amonakov at ispras dot ru>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 15 Jul 2017 23:47:46 +0300
- Subject: [PATCH 3/6] lra-assigns.c: fix pseudo_compare_func
- Authentication-results: sourceware.org; auth=none
- References: <20170715204749.24398-1-amonakov@ispras.ru>
This comparator lacks anti-commutativity and can indicate
A < B < A if both A and B satisfy non_spilled_static_chain_regno_p.
Proceed to following tie-breakers in that case.
(it looks like the code incorrectly assumes that at most one register
in the array will satisfy non_spilled_static_chain_regno_p)
* lra-assigns.c (pseudo_compare_func): Fix comparison step based on
non_spilled_static_chain_regno_p.
---
gcc/lra-assigns.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
index 42556d3..2aadeef 100644
--- a/gcc/lra-assigns.c
+++ b/gcc/lra-assigns.c
@@ -253,10 +253,9 @@ pseudo_compare_func (const void *v1p, const void *v2p)
/* Assign hard reg to static chain pointer first pseudo when
non-local goto is used. */
- if (non_spilled_static_chain_regno_p (r1))
- return -1;
- else if (non_spilled_static_chain_regno_p (r2))
- return 1;
+ if ((diff = (non_spilled_static_chain_regno_p (r2)
+ - non_spilled_static_chain_regno_p (r1))) != 0)
+ return diff;
/* Prefer to assign more frequently used registers first. */
if ((diff = lra_reg_info[r2].freq - lra_reg_info[r1].freq) != 0)
--
1.8.3.1