* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
@ 2021-12-13 10:55 ` hubicka at gcc dot gnu.org
2021-12-13 12:26 ` marxin at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-12-13 10:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |aldyh at gcc dot gnu.org,
| |law at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
--- Comment #1 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
This is table to fit 80 column limit
Profile consistency report:
Pass dump id and name |dynamic mismatch
|in count |out prob
79i cp | 793393361 +793393361| 0
83i inline | 10286436405 +9493043044| 15236 +15236
92t fixup_cfg | 10286436405 | 15236
97t ompdevlow | 10286436405 | 15236
99t adjust_alignment | 10286436405 | 15236
100t ccp | 10489595202 +203158797| 1581960 +1566724
101t objsz | 10489595202 | 1581960
103t cunrolli | 10056896600 -432698602| 1581960
104t backprop | 10056896600 | 1581960
105t phiprop | 10056896600 | 1581960
106t forwprop | 10159477423 +102580823| 1581960
107t alias | 10159477423 | 1581960
108t retslot | 10159477423 | 1581960
109t fre | 19869551210 +9710073787| 15236 -1566724
110t mergephi | 20025371186 +155819976| 15236
11t threadfull | 202402568370 +182377197184| 972775135 +97275989
112t vrp | 216458254352 +14055685982| 1014740538 +41965403
113t dse | 216259198094 -199056258| 1014740522 -16
114t dce | 213766589405 -2492608689| 1010738219 -4002303
115t stdarg | 213766589405 | 1010738219
116t cdce | 213766589405 | 1010738219
117t cselim | 213766434213 -155192| 1010738219
118t copyprop | 212518014812 -1248419401| 1003793990 -6944229
119t ifcombine | 215021849380 +2503834568| 1175015399 +171221409
120t mergephi | 213958226983 -1063622397| 1170269374 -4746025
121t phiopt | 213278698412 -679528571| 1169780184 -489190
122t tailr | 213591827870 +313129458| 1169780184
123t ch | 231773845670 +18182017800| 1169779155 -1029
124t cplxlower | 231773845670 | 1169779155
125t sra | 231773845670 | 1169779155
126t thread | 282837813276 +51063967606| 1884527067 +714747912
127t dom | 289296055849 +6458242573| 1881062486 -3464580
128t copyprop | 288791521291 -504534558| 1880452325 -610161
129t isolate-paths | 289175243159 +383721868| 1887100849 +6648524
130t reassoc | 295644564738 +6469321579| 1886368237 -732612
131t dce | 294937412703 -707152035| 1878493133 -7875104
132t forwprop | 297646371403 +2708958700| 1878493133
133t phiopt | 297639291119 -7080284| 1878493133
134t ccp | 297550679459 -88611660| 1893125633 +14632500
135t sincos | 297550679459 | 1893125633
136t bswap | 297550679459 | 1893125633
137t laddress | 297550679459 | 1893125633
138t lim | 297859756610 +309077151| 1893125633
139t walloca | 297859756610 | 1893125633
140t pre | 299154507133 +1294750523| 1885986610 -7139023
141t sink | 299366883910 +212376777| 1855713098 -30273512
145t dse | 299366883910 | 1855713098
146t dce | 299440495723 +73611813| 1855713098
147t fix_loops | 299440495723 | 1855713098
148t loop | 299440495723 | 1855713098
149t loopinit | 299440495723 | 1855713098
150t unswitch | 301091048942 +1650553219| 1855713098
151t sccp | 301090909602 -139340| 1855713098
152t lsplit | 301901055378 +810145776| 1855713098
153t lversion | 301901055378 | 1855713098
154t unrolljam | 301901055378 | 1855713098
55t cddce | 400398657031 +98497601653| 1723477545 -132235553
156t ivcanon | 400399330048 +673017| 1723477545
157t ldist | 396226006072 -4173323976| 2013657886 +290180341
158t linterchange | 396226006072 | 2013657886
159t copyprop | 396225913851 -92221| 2013657886
166t ompexpssa | 396225913851 | 2013657886
167t ch_vect | 396265259912 +39346061| 2013657886
168t ifcvt | 399080908207 +2815648295| 3365644947 +1351987061
169t vect | 395362097676 -3718810531| 2013657886 -1351987061
170t dce | 395133116739 -228980937| 2013657886
171t pcom | 395133116739 | 2013657886
172t cunroll 6| 478680255671 +83547138932| 1999297268 -1436061
173t fre | 478355091001 -325164670| 1999297268
174t dse | 478355091001 | 1999297268
175t slp | 478355091001 | 1999297268
177t ivopts | 478355091001 | 1999297268
178t lim | 478355091001 | 1999297268
179t loopdone | 478267981458 -87109543| 1999297268
180t no_loop | 478267981458 | 1999297268
181t slp | 478267981458 | 1999297268
183t veclower2 | 477128368553 -1139612905| 1999297226 -42
184t switchlower 04| 1380672969073 +903544600520| 1921470715 -7782
186t reassoc | 1380025901003 -647068070| 1921462330 -838
187t slsr | 1380025901003 | 1921462330
188t split-paths | 1380032502398 +6601395| 1921462330
189t tracer | 1272463552867 -107568949531| 1909758769 -117035
190t fre | 1291101339405 +18637786538| 1905694277 -406449
191t thread | 1260887440991 -30213898414| 3227986771 +132229249
192t dom | 1265636026287 +4748585296| 3398605099 +17061832
193t strlen | 1265636026287 | 3398605099
194t threadfull | 1273228200834 +7592174547| 3495419473 +9681437
195t vrp | 1273076379738 -151821096| 4379683658 +88426418
196t ccp | 1272303409980 -772969758| 4385826012 +614235
197t wrestrict | 1272303409980 | 4385826012
198t dse | 1272023199564 -280210416| 4385816013 -999
199t cddce 6| 1369149644581 +97126445017| 4385012766 -8032
200t forwprop | 1369582809624 +433165043| 4380754912 -425785
201t phiopt | 1369413694596 -169115028| 4371615103 -913980
202t fab | 1356127299769 -13286394827| 4359973464 -1164163
203t widening_mul | 1356127299769 | 4359973464
204t sink | 1352510559484 -3616740285| 4359971169 -229
205t store-merging | 1352510559484 | 4359971169
206t tailc | 1352494254576 -16304908| 4359971169
207t dce | 1350206240191 -2288014385| 4359971169
208t crited | 1350206240191 | 4359971169
209t uninit | 1350206240191 | 4359971169
210t local-pure-const | 1350349863074 +143622883| 4359971169
211t modref | 1350349863074 | 4359971169
212t uncprop | 1350349863074 | 4359971169
246t nrv | 1350349863074 | 4359971169
247t isel | 1350349863074 | 4359971169
250t optimized | 1350486491782 +136628708| 4380125028 +2015385
251t waccess | 1350486491782 | 4380125028
252r expand 1| 1300300159576 -50186332206| 3055506535 -13246184
253r vregs | 1300300159576 | 3055506535
254r into_cfglayout | 1300334045064 +33885488| 2856914371 -19859216
255r jump | 1300487250854 +153205790| 2856927565 +1319
256r subreg1 | 1300487250854 | 2856927565
257r dfinit | 1300487250854 | 2856927565
258r cse1 | 1300444468450 -42782404| 2856913789 -1377
259r fwprop1 | 1300444468450 | 2856913789
260r cprop | 1302497316424 +2052847974| 2840122245 -1679154
261r rtl pre | 1302497316424 | 2840122245
262r hoist | 1302497316424 | 2840122245
263r cprop | 1301012893039 -1484423385| 2839953333 -16891
265r cse_local | 1301012893039 | 2839953333
266r ce1 | 1297874035422 -3138857617| 2805149089 -3480424
267r reginfo | 1297874035422 | 2805149089
268r loop2 | 1297874035422 | 2805149089
269r loop2_init | 1297874035422 | 2805149089
270r loop2_invariant | 1297874035422 | 2805149089
271r loop2_unroll | 1311747865069 +13873829647| 2805149089
273r loop2_done | 1317456278918 +5708413849| 2805149089
276r cprop | 1334139229371 +16682950453| 2805149089
277r stv | 1334139229371 | 2805149089
278r cse2 | 1334078649228 -60580143| 2805149089
279r dse1 | 1334078649228 | 2805149089
280r fwprop2 | 1333290149948 -788499280| 2805149089
282r init-regs | 1333290149948 | 2805149089
283r ud_dce | 1333290149948 | 2805149089
284r combine | 1333648234805 +358084857| 2805149089
286r stv | 1333648234805 | 2805149089
287r ce2 | 1333465104885 -183129920| 2804833682 -31540
288r jump_after_combine| 1334075792643 +610687758| 2813150500 +831681
289r bbpart | 1333936023873 -139768770| 2813142257 -824
290r outof_cfglayout | 1333936023873 | 2813142257
291r split1 | 1333936023873 | 2813142257
292r subreg3 | 1333936023873 | 2813142257
294r mode_sw | 1333936023873 | 2813142257
295r asmcons | 1333936023873 | 2813142257
300r ira | 1333936023873 | 2813142257
301r reload | 1334581013551 +644989678| 2812625999 -51625
303r postreload | 1334581013551 | 2812625999
304r gcse2 | 1334581013551 | 2812625999
305r split2 | 1334581013551 | 2812625999
306r ree | 1334581013551 | 2812625999
307r cmpelim | 1334581013551 | 2812625999
309r pro_and_epilogue | 1341177127695 +6596114144| 2812611798 -1420
309r dse2 | 1341177127695 | 2812611798
310r csa | 1341177127695 | 2812611798
311r jump2 | 1394955038853 +53777911158| 2811994770 -61702
312r compgotos | 1394955038853 | 2811994770
314r peephole2 | 1394955038853 | 2811994770
315r ce3 | 1394975083423 +20044570| 2811994770
317r cprop_hardreg | 1394975083423 | 2811994770
318r rtl_dce | 1394975083423 | 2811994770
319r bbro | 1358424822396 -36550261027| 2811994765 -
320r split3 | 1358424822396 | 2811994765
321r sched2 | 1358424822396 | 2811994765
323r stack | 1358424822396 | 2811994765
324r zero_call_used_reg| 1358424822396 | 2811994765
325r alignments | 1358424822396 | 2811994765
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
2021-12-13 10:55 ` [Bug tree-optimization/103680] " hubicka at gcc dot gnu.org
@ 2021-12-13 12:26 ` marxin at gcc dot gnu.org
2021-12-13 13:56 ` pinskia at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-13 12:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=101301
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
I can confirm the switch lowering pass breaks profile update, it's mentioned
here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101301#c10 and I'm planning
to work on that in stage 3/4.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
2021-12-13 10:55 ` [Bug tree-optimization/103680] " hubicka at gcc dot gnu.org
2021-12-13 12:26 ` marxin at gcc dot gnu.org
@ 2021-12-13 13:56 ` pinskia at gcc dot gnu.org
2022-01-04 9:54 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-13 13:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=25623
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
jump threading one was filed a long time ago as PR 25623.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
` (2 preceding siblings ...)
2021-12-13 13:56 ` pinskia at gcc dot gnu.org
@ 2022-01-04 9:54 ` rguenth at gcc dot gnu.org
2022-04-09 21:27 ` hubicka at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-04 9:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
And for CFG cleanup there's no profile updating done when passes leave CFG
update to it by simplifying conditions to if (0) or if (1). One could argue
that
"late" simplifications simply make the guessed profile bogus - for feedback
profiles the cut paths should have zero count already.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
` (3 preceding siblings ...)
2022-01-04 9:54 ` rguenth at gcc dot gnu.org
@ 2022-04-09 21:27 ` hubicka at gcc dot gnu.org
2022-11-30 13:04 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hubicka at gcc dot gnu.org @ 2022-04-09 21:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
--- Comment #5 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
The cfgcleanup logic is consistent assuming that your profile was consistent on
the input (i.e. read from profile feedback). If you
1) read profile
2) do optimization and prove that given if conditional is true
then you should also have 100% probability on the "true" edge so doing nothing
in cfgcleanup is correct.
Now of course what can happen is that you guess profile or
1) read profile
2) duplicate code
3) prove if conditonal always true in one of the copy.
In this case fixing up profile locally is not possible (since it is also wrong
in the other copy), so we opt doing nothing which keeps errors sort of
contained and we need to live that profile is somethimes inconsistent.
So cfgcleanup behaviour is by design.
However if you do threading there is way to update the profile and logic for
that iis n update_bb_profile_for_threading. If guessed profile was consistent
with the thread, it will update profile well and it will drop message to a dump
file otherwise.
Now the problem is that each time profiling code is updated the interface to
this function is lost. I tried to get it fixed but got lost in the new code.
/* An edge originally destinating BB of COUNT has been proved to
leave the block by TAKEN_EDGE. Update profile of BB such that edge E can be
redirected to destination of TAKEN_EDGE.
This function may leave the profile inconsistent in the case TAKEN_EDGE
frequency or count is believed to be lower than COUNT
respectively. */
void
update_bb_profile_for_threading (basic_block bb,
profile_count count, edge taken_edge)
So the interface is quite simple. I have to re-read the new updating code
since I no longer recall where I got lost, but perhaps if you are familiar with
it, you can write in the update?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
` (4 preceding siblings ...)
2022-04-09 21:27 ` hubicka at gcc dot gnu.org
@ 2022-11-30 13:04 ` cvs-commit at gcc dot gnu.org
2023-06-28 9:16 ` hubicka at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-30 13:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:
https://gcc.gnu.org/g:4fa25a7eb322f0a003c1eb15680c71ece345e01e
commit r13-4409-g4fa25a7eb322f0a003c1eb15680c71ece345e01e
Author: Martin Liska <mliska@suse.cz>
Date: Mon Jan 24 15:45:38 2022 +0100
Improve profile handling in switch lowering.
PR tree-optimization/101301
PR tree-optimization/103680
gcc/ChangeLog:
* tree-switch-conversion.cc (bit_test_cluster::emit):
Handle correctly remaining probability.
(switch_decision_tree::try_switch_expansion): Fix BB's count
where a cluster expansion happens.
(switch_decision_tree::emit_cmp_and_jump_insns): Fill up also
BB count.
(switch_decision_tree::do_jump_if_equal): Likewise.
(switch_decision_tree::emit_case_nodes): Handle special case
for BT expansion which can also fallback to a default BB.
* tree-switch-conversion.h (cluster::cluster): Add
m_default_prob probability.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
` (5 preceding siblings ...)
2022-11-30 13:04 ` cvs-commit at gcc dot gnu.org
@ 2023-06-28 9:16 ` hubicka at gcc dot gnu.org
2023-06-28 16:47 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hubicka at gcc dot gnu.org @ 2023-06-28 9:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-06-28
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #7 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
a simple testcase:
test (int i)
{
if (__builtin_expect_with_probability (i > 5, 1, 0.6))
foo ();
}
test2(int i)
{
test (i);
if (__builtin_expect_with_probability (i > 4, 1, 0.7))
foo ();
}
this is can be updated quite easily, but we still fail.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
` (6 preceding siblings ...)
2023-06-28 9:16 ` hubicka at gcc dot gnu.org
@ 2023-06-28 16:47 ` pinskia at gcc dot gnu.org
2023-06-28 21:30 ` hubicka at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-28 16:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |25623
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #7)
> a simple testcase:
> test (int i)
> {
> if (__builtin_expect_with_probability (i > 5, 1, 0.6))
> foo ();
> }
> test2(int i)
> {
> test (i);
> if (__builtin_expect_with_probability (i > 4, 1, 0.7))
> foo ();
> }
> this is can be updated quite easily, but we still fail.
That is exactly bug 25623 comment #1.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25623
[Bug 25623] jump threading/cfg cleanup messes up "incoming counts" for some BBs
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
` (7 preceding siblings ...)
2023-06-28 16:47 ` pinskia at gcc dot gnu.org
@ 2023-06-28 21:30 ` hubicka at gcc dot gnu.org
2023-06-30 16:18 ` hubicka at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hubicka at gcc dot gnu.org @ 2023-06-28 21:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
--- Comment #9 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
bug 25623 comment #1 is different since __builtin_abort makes initial guessed
profile inconsistent with the correlated conditionals.
That is reason why I added explicit __builtin_expect_with_probability to make
the profile consistent. This is bug that got in after one of several threading
rewrites.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
` (8 preceding siblings ...)
2023-06-28 21:30 ` hubicka at gcc dot gnu.org
@ 2023-06-30 16:18 ` hubicka at gcc dot gnu.org
2023-06-30 16:22 ` hubicka at gcc dot gnu.org
2023-07-01 7:11 ` cvs-commit at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: hubicka at gcc dot gnu.org @ 2023-06-30 16:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
--- Comment #10 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I am testing:
diff --git a/gcc/cfg.cc b/gcc/cfg.cc
index 897ef534ff5..defdf679f7b 100644
--- a/gcc/cfg.cc
+++ b/gcc/cfg.cc
@@ -922,7 +922,6 @@ update_bb_profile_for_threading (basic_block bb,
fprintf (dump_file, "bb %i count became negative after threading",
bb->index);
}
- bb->count -= count;
/* Compute the probability of TAKEN_EDGE being reached via threaded edge.
Watch for overflows. */
@@ -934,8 +933,8 @@ update_bb_profile_for_threading (basic_block bb,
{
if (dump_file)
{
- fprintf (dump_file, "Jump threading proved probability of edge "
- "%i->%i too small (it is ",
+ fprintf (dump_file, "Jump threading proved that the probability of
edge "
+ "%i->%i was originally estimated too small (it is ",
taken_edge->src->index, taken_edge->dest->index);
taken_edge->probability.dump (dump_file);
fprintf (dump_file, " should be ");
@@ -945,6 +944,8 @@ update_bb_profile_for_threading (basic_block bb,
prob = taken_edge->probability.apply_scale (6, 8);
}
+ bb->count -= count;
+
/* Now rescale the probabilities. */
taken_edge->probability -= prob;
prob = prob.invert ();
This fixes the trivial testcase in comment #9
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
` (9 preceding siblings ...)
2023-06-30 16:18 ` hubicka at gcc dot gnu.org
@ 2023-06-30 16:22 ` hubicka at gcc dot gnu.org
2023-07-01 7:11 ` cvs-commit at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: hubicka at gcc dot gnu.org @ 2023-06-30 16:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
--- Comment #11 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
The following are passes affecting mismatches for tramp3d -O3 build:
107t cunrolli | 85 +77
110t forwprop | 87 +2
113t fre | 151 +64
115t threadfull | 474 +323
116t vrp | 379 -95
127t ch | 3106 +2729
130t thread | 3166 +60
131t dom | 3036 -130
159t cddce | 3146 +109
195t fre | 1232 +10
196t thread | 1259 +27
197t dom | 1249 -10
199t threadfull | 1275 +26
200t vrp | 1264 -11
211t cddce | 1264 +14
264r cprop | 1174 +13
275r loop2_unroll | 1180 +8
312r pro_and_epilogue | 1204 +21
315r jump2 | 1245 +41
So jump threading still produces mismatches, but I will need to look more if
these are really conflicting profiles or another updating bug.
Not sure what happens in ch.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/103680] Jump threading and switch corrupts profile
2021-12-13 10:51 [Bug tree-optimization/103680] New: Jump threading and switch corrupts profile hubicka at gcc dot gnu.org
` (10 preceding siblings ...)
2023-06-30 16:22 ` hubicka at gcc dot gnu.org
@ 2023-07-01 7:11 ` cvs-commit at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-01 7:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103680
--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jan Hubicka <hubicka@gcc.gnu.org>:
https://gcc.gnu.org/g:02460c0b8c9000359a09440f9532664a7835f158
commit r14-2228-g02460c0b8c9000359a09440f9532664a7835f158
Author: Jan Hubicka <jh@suse.cz>
Date: Sat Jul 1 09:09:39 2023 +0200
Fix update_bb_profile_for_threading
Fix profile some of profile mismatched caused by profile updating.
It seems that I misupdated update_bb_profile_for_threading in 2017 which
results in invalid updates from rtl threading and threadbackwards.
update_bb_profile_for_threading knows that some paths to BB are being
redirected elsehwere and those paths will exit from BB with E. So it needs
to
determine probability of the duplicated path and redistribute probablities.
For some reaosn however the conditonal probability of redirected path is
computed after its counts is subtracted which is wrong and often results in
probability greater than 100%.
I also fixed error mesage. Compilling tramp3d I now get following passes
producing mismpatches:
Pass dump id and name |static mismatcdynamic mismatch
|in count |in count
113t fre | 2 +2| 0
114t mergephi | 2 | 0
115t threadfull | 2 | 0
116t vrp | 2 | 0
127t ch | 307 +305| 347194302 +347194302
130t thread | 313 +6| 347221478 +27176
131t dom | 321 +8| 346841121 -380357
134t reassoc | 323 +2| 346841121
136t forwprop | 327 +4| 347026371 +185250
144t pre | 326 -1| 347040926 +14555
172t ifcvt | 338 +2| 347218249 +156280
173t vect | 409 +71| 356357418 +9139169
176t cunroll | 377 -32| 126071925 -230285493
183t loopdone | 376 -1| 126015489 -56436
194t tracer | 379 +3| 127258199 +1242710
197t dom | 375 -4| 128352165 +1093966
199t threadfull | 379 +4| 128526112 +173947
200t vrp | 381 +2| 128724673 +198561
204t dce | 374 -7| 128632495 -92178
206t sink | 370 -4| 128618043 -14452
211t cddce | 372 +2| 128632495 +14452
248t ehcleanup | 370 -2| 128618755 -13740
255t optimized | 362 -8| 128576810 -41945
256r expand | 356 -6| 128899768 +322958
258r into_cfglayout | 353 -3| 129051765 +151997
259r jump | 354 +1| 129051765
262r cse1 | 353 -1| 129051765
275r loop2_unroll | 355 +2| 132182110 +3130345
277r loop2_done | 354 -1| 132182109 -1
312r pro_and_epilogue | 371 +17| 132222324 +40215
323r bbro | 375 +4| 132095926 -126398
Without the patch at jump2 time we get over 432 mismatches, so 15%
improvement. Some of the mismathces are unavoidable.
I think ch mismatches are mostly due to loop header copying where the
header
condition constant propagates. Most common case should be threadable in
early
optimizations and we also could do better on profile updating here.
Bootstrapped/regtested x6_64-linux, comitted.
gcc/ChangeLog:
PR tree-optimization/103680
* cfg.cc (update_bb_profile_for_threading): Fix profile update;
make message clearer.
gcc/testsuite/ChangeLog:
PR tree-optimization/103680
* gcc.dg/tree-ssa/pr103680.c: New test.
* gcc.dg/tree-prof/cmpsf-1.c: Un-xfail.
^ permalink raw reply [flat|nested] 13+ messages in thread