https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94042
--- Comment #19 from Martin Liška <marxin at gcc dot gnu.org> ---
Ok, using the following patch:
diff --git a/gcc/dbgcnt.def b/gcc/dbgcnt.def
index 232b192..7e45e46 100644
--- a/gcc/dbgcnt.def
+++ b/gcc/dbgcnt.def
@@ -173,6 +173,7 @@ DEBUG_COUNTER (if_conversion_tree)
DEBUG_COUNTER (ipa_sra_params)
DEBUG_COUNTER (ipa_sra_retvalues)
DEBUG_COUNTER (ira_move)
+DEBUG_COUNTER (irahonor)
DEBUG_COUNTER (ivopts_loop)
DEBUG_COUNTER (local_alloc_for_sched)
DEBUG_COUNTER (match)
diff --git a/gcc/ira-color.c b/gcc/ira-color.c
index a2bf108..908c717 100644
--- a/gcc/ira-color.c
+++ b/gcc/ira-color.c
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see
#include "ira-int.h"
#include "reload.h"
#include "cfgloop.h"
+#include "dbgcnt.h"
typedef struct allocno_hard_regs *allocno_hard_regs_t;
@@ -1925,8 +1926,9 @@ assign_hard_reg (ira_allocno_t a, bool retry_p)
}
if (min_cost > cost)
min_cost = cost;
+ bool honor = dbg_cnt(irahonor);
if (min_full_cost > full_cost
- || (!HONOR_REG_ALLOC_ORDER && min_full_cost == full_cost
+ || (honor && !HONOR_REG_ALLOC_ORDER && min_full_cost == full_cost
&& best_hard_regno > hard_regno))
{
min_full_cost = full_cost;
First bad: -fdbg-cnt=irahonor:788382
Last good: -fdbg-cnt=irahonor:788381
The change is only in function tsubst_template_arg:
diff -u /tmp/good.s /tmp/bad.s -U99999
--- /tmp/good.s 2020-03-06 09:33:27.548791681 +0100
+++ /tmp/bad.s 2020-03-06 09:48:46.504419609 +0100
@@ -1,38 +1,37 @@
mr. r7,r3
beq 0x104c91x0 <._Z19tsubst_template_argP9tree_nodeS0_iS0_+>
lhz r8,0(r7)
addis r9,r2,-128
addi r9,r9,29456
rldicr r8,r8,2,61
lwzx r9,r9,r8
cmpwi r9,2
beq 0x104c91x0 <._Z19tsubst_template_argP9tree_nodeS0_iS0_+>
andi. r9,r5,2
addis r9,r2,13
addi r9,r9,3152
-ld r8,0(r9)
+stdu r1,-128(r1)
+ld r0,0(r9)
bne 0x104c9160 <._Z19tsubst_template_argP9tree_nodeS0_iS0_+160>
-std r31,-8(r1)
+std r31,120(r1)
nop
addi r31,r2,22820
-cmpld r7,r8
-stdu r1,-128(r1)
+cmpld r7,r0
lwa r9,0(r31)
addi r10,r9,1
stw r10,0(r31)
beq 0x104c914x <._Z19tsubst_template_argP9tree_nodeS0_iS0_+>
mflr r0
li r7,1
std r0,144(r1)
bl 0x1049f300 <._Z11tsubst_exprP9tree_nodeS0_iS0_b.part.0>
ld r0,144(r1)
lwz r9,0(r31)
-mr r8,r3
mtlr r0
addi r9,r9,-1
extsw r9,r9
-addi r1,r1,128
stw r9,0(r31)
-mr r3,r8
-ld r31,-8(r1)
+ld r31,120(r1)
+mr r3,r0
+addi r1,r1,128
blr
Optimized dump of the problematic function:
tsubst_template_arg (union tree_node * t, union tree_node * args,
tsubst_flags_t complain, union tree_node * in_decl)
{
union tree_node * r;
short unsigned int _1;
int _2;
tree_code_class _3;
union tree_node * pretmp_14;
int _15;
int c_inhibit_evaluation_warnings.2997_16;
int _17;
int pretmp_18;
union tree_node * _19;
union tree_node * _21;
int prephitmp_27;
int _30;
union tree_node * _34;
<bb 2> [local count: 1073741823]:
if (t_6(D) == 0B)
goto <bb 8>; [30.00%]
else
goto <bb 3>; [70.00%]
<bb 3> [local count: 751619280]:
_1 = t_6(D)->base.code;
_2 = (int) _1;
_3 = tree_code_type[_2];
if (_3 == 2)
goto <bb 4>; [20.24%]
else
goto <bb 5>; [79.76%]
<bb 4> [local count: 152127741]:
r_12 = tsubst (t_6(D), args_9(D), complain_8(D), in_decl_10(D)); [tail call]
goto <bb 8>; [100.00%]
<bb 5> [local count: 599491539]:
_15 = complain_8(D) & 2;
pretmp_14 = global_trees[0];
if (_15 == 0)
goto <bb 6>; [50.00%]
else
goto <bb 9>; [50.00%]
<bb 6> [local count: 299745769]:
c_inhibit_evaluation_warnings.2997_16 = c_inhibit_evaluation_warnings;
_17 = c_inhibit_evaluation_warnings.2997_16 + 1;
c_inhibit_evaluation_warnings = _17;
if (t_6(D) == pretmp_14)
goto <bb 7>; [30.95%]
else
goto <bb 10>; [69.05%]
<bb 7> [local count: 299745769]:
# _21 = PHI <_34(10), pretmp_14(6)>
# prephitmp_27 = PHI <_30(10), c_inhibit_evaluation_warnings.2997_16(6)>
c_inhibit_evaluation_warnings = prephitmp_27;
<bb 8> [local count: 1073741824]:
# r_5 = PHI <t_6(D)(2), r_12(4), _21(7), _19(11), pretmp_14(9)>
return r_5;
<bb 9> [local count: 299745770]:
if (t_6(D) == pretmp_14)
goto <bb 8>; [30.95%]
else
goto <bb 11>; [69.05%]
<bb 10> [local count: 206974454]:
_34 = _Z11tsubst_exprP9tree_nodeS0_iS0_b.part.0 (t_6(D), args_9(D),
complain_8(D), in_decl_10(D), 1);
pretmp_18 = c_inhibit_evaluation_warnings;
_30 = pretmp_18 + -1;
goto <bb 7>; [100.00%]
<bb 11> [local count: 206974454]:
_19 = _Z11tsubst_exprP9tree_nodeS0_iS0_b.part.0 (t_6(D), args_9(D),
complain_8(D), in_decl_10(D), 1); [tail call]
goto <bb 8>; [100.00%]
}