Message ID | 20180111081643.GA54969@kam.mff.cuni.cz |
---|---|
State | New |
Headers | show |
Series | Fix predictive commoning profile update ICE | expand |
Hi, this patch fixes the profile misupdate. Isolate-path was actually dropping to 0 the BB on the likely path rather than the duplicate. Will commit it after bootstrap/regtestest on x86-64 finishes. Honza PR middle-end/83189 * gimple-ssa-isolate-paths.c (isolate_path): Fix profile update. Index: gimple-ssa-isolate-paths.c =================================================================== --- gimple-ssa-isolate-paths.c (revision 256479) +++ gimple-ssa-isolate-paths.c (working copy) @@ -138,6 +138,7 @@ isolate_path (basic_block bb, basic_bloc edge_iterator ei; edge e2; bool impossible = true; + profile_count count = e->count (); for (si = gsi_start_bb (bb); gsi_stmt (si) != stmt; gsi_next (&si)) if (stmt_can_terminate_bb_p (gsi_stmt (si))) @@ -154,11 +155,12 @@ isolate_path (basic_block bb, basic_bloc if (!duplicate) { duplicate = duplicate_block (bb, NULL, NULL); - bb->count = profile_count::zero (); + duplicate->count = profile_count::zero (); if (!ret_zero) for (ei = ei_start (duplicate->succs); (e2 = ei_safe_edge (ei)); ) remove_edge (e2); } + bb->count -= count; /* Complete the isolation step by redirecting E to reach DUPLICATE. */ e2 = redirect_edge_and_branch (e, duplicate);
Index: testsuite/gfortran.fortran-torture/compile/pr83189.f90 =================================================================== --- testsuite/gfortran.fortran-torture/compile/pr83189.f90 (revision 256478) +++ testsuite/gfortran.fortran-torture/compile/pr83189.f90 (working copy) @@ -1,30 +0,0 @@ +Module radin_mod + INTEGER, PARAMETER :: DP = selected_real_kind(14,200) +Contains + Subroutine SPLIFT (X,Y,YP,YPP,N,IERR,ISX,A1,B1,AN,BN) + Integer, Intent(in) :: N,ISX + Real(dp), Intent(in) :: X(N),Y(N),A1,B1,AN,BN + Real(dp), Intent(out) :: YP(N),YPP(N) + Real(dp), Allocatable, Dimension(:,:) :: W + NM1 = N-1 + NM2 = N-2 + If (ISX.Gt.0) GO TO 40 + Do I=2,N + If (X(I)-X(I-1) .Le. 0) Then + IERR = 3 + Return + Endif + End Do + Allocate(W(N,3)) +40 YPP(1) = 4*B1 + DOLD = (Y(2)-Y(1))/W(2,2) + Do I=2,NM2 + DNEW = (Y(I+1) - Y(I))/W(I+1,2) + YPP(I) = 6*(DNEW - DOLD) + YP(I) = DOLD + DOLD = DNEW + End Do + Return + End Subroutine SPLIFT +End Module radin_mod + Index: tree-ssa-loop-manip.c =================================================================== --- tree-ssa-loop-manip.c (revision 256441) +++ tree-ssa-loop-manip.c (working copy) @@ -1378,7 +1378,8 @@ tree_transform_and_unroll_loop (struct l { /* Avoid dropping loop body profile counter to 0 because of zero count in loop's preheader. */ - freq_e = freq_e.force_nonzero (); + if (freq_h.nonzero_p () && !(freq_e == profile_count::zero ())) + freq_e = freq_e.force_nonzero (); scale_loop_frequencies (loop, freq_e.probability_in (freq_h)); }