https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103270
--- Comment #3 from luoxhu at gcc dot gnu.org ---
The profile count is correct but something wrong with edge probability, and it
turns out that r12-4526 exposes a long-existing issue in
profile_estimate:predict_extra_loop_exits, when searching extra exit edges for
inner loop, it goes out and find a edge belongs to *outer loop*, setting that
edge with predict value 33%, then predict_loops won't reset that edge for outer
loop.
I drafted a patch to ignore EDGE_DFS_BACK edges when iterating in
predict_extra_loop_exits, then inner loop becomes hot again.
diff base/pr103270.c.047t.profile_estimate
patched/pr103270.c.047t.profile_estimate -U15
Predictions for bb 5
1 edges in bb 5 predicted to even probabilities
Predictions for bb 6
- first match heuristics: 33.00%
- combined heuristics: 33.00%
+ first match heuristics: 91.67%
+ combined heuristics: 91.67%
opcode values nonequal (on trees) heuristics of edge 6->11 (ignored): 66.00%
- extra loop exit heuristics of edge 6->11: 33.00%
+ loop iterations heuristics of edge 6->7: 8.33%
Predictions for bb 11
1 edges in bb 11 predicted to even probabilities
Predictions for bb 7
1 edges in bb 7 predicted to even probabilitie
…
- <bb 2> [local count: 88915474]:
+ <bb 2> [local count: 6029625]:
goto <bb 8>; [100.00%]
- <bb 3> [local count: 354334800]:
+ <bb 3> [local count: 536870913]:
_1 = *i_19(D);
_2 = a_4 & c_6;
_3 = _1 + _2;
*i_19(D) = _3;
- <bb 4> [local count: 708669601]:
+ <bb 4> [local count: 1073741824]:
# c_6 = PHI <c_7(11), b_5(3)>
# d_8 = PHI <0(11), 1(3)>
if (d_8 == 0)
goto <bb 3>; [50.00%]
else
goto <bb 5>; [50.00%]
- <bb 5> [local count: 354334800]:
+ <bb 5> [local count: 536870913]:
# c_21 = PHI <c_6(4)>
b_18 = b_5 + -1;
- <bb 6> [local count: 1073741824]:
+ <bb 6> [local count: 585656064]:
# b_5 = PHI <0(10), b_18(5)>
# c_7 = PHI <0(10), c_21(5)>
if (b_5 != -11)
- goto <bb 11>; [33.00%]
+ goto <bb 11>; [91.67%]
else
- goto <bb 7>; [67.00%]
+ goto <bb 7>; [8.33%]
- <bb 11> [local count: 354334800]:
+ <bb 11> [local count: 536870913]:
goto <bb 4>; [100.00%]
- <bb 7> [local count: 719407024]:
+ <bb 7> [local count: 48785151]:
a_16 = a_4 + 1;
- <bb 8> [local count: 808322498]:
+ <bb 8> [local count: 54814777]:
# a_4 = PHI <a_12(D)(2), a_16(7)>
if (a_4 <= 4)
goto <bb 10>; [89.00%]
else
goto <bb 9>; [11.00%]
- <bb 10> [local count: 719407024]:
+ <bb 10> [local count: 48785151]:
goto <bb 6>; [100.00%]
- <bb 9> [local count: 88915474]:
+ <bb 9> [local count: 6029625]:
return;