diff mbox

[3/6] lra-assigns.c: fix pseudo_compare_func

Message ID 20170715204749.24398-4-amonakov@ispras.ru
State New
Headers show

Commit Message

Alexander Monakov July 15, 2017, 8:47 p.m. UTC
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(-)

Comments

Jeff Law July 19, 2017, 6:48 a.m. UTC | #1
On 07/15/2017 02:47 PM, Alexander Monakov wrote:
> 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.
OK.
jeff
diff mbox

Patch

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)