Hi, with -fprofile-report is it now again possible to produce quite useful stats on what passes misupdates profile. I am attaching preport for FDO+LTO build of clang binary. The column dynamic mismatch is most relevant and show number of executions of BB where profile is mismatched. Clearly threadfull, vrp, ch, dom and switchlower seems main offenders. cddce is also very high, but I think it is just making previous mismatches worse - will look into that It seems that the ranger threading revamp dropped profile updating code. Andy, Jeff, I wonder what are your thoughts/plans on updating the profile here? Profile consistency report: Pass dump id and name |static mismatch |dynamic mismatch |overall | |in count |out prob |in count |out prob |size |time | 79i cp | 1245 +1245| 23 +23| 793393361 +793393361| 0 | 6865717 | 38369447330388 | 83i inline | 2985 +1740| 204 +181| 10286436405 +9493043044| 15236 +15236| 10407224 +51.6%| 30175876351621 -21.4%| 92t fixup_cfg | 2985 | 204 | 10286436405 | 15236 | 10407224 | 30175876351621 | 97t ompdevlow | 2985 | 204 | 10286436405 | 15236 | 10407224 | 30175876351621 | 99t adjust_alignment | 2985 | 204 | 10286436405 | 15236 | 10407224 | 30175876351621 | 100t ccp | 3690 +705| 205 +1| 10489595202 +203158797| 1581960 +1566724| 10379522 -0.3%| 29996985353603 -0.6%| 101t objsz | 3690 | 205 | 10489595202 | 1581960 | 10379522 | 29996985353603 | 103t cunrolli | 3828 +138| 205 | 10056896600 -432698602| 1581960 | 10378081 -0.0%| 29950281172451 -0.2%| 104t backprop | 3828 | 205 | 10056896600 | 1581960 | 10378081 | 29950281172451 | 105t phiprop | 3828 | 205 | 10056896600 | 1581960 | 10387153 +0.1%| 29949755030810 -0.0%| 106t forwprop | 3843 +15| 205 | 10159477423 +102580823| 1581960 | 10378573 -0.1%| 29895061666317 -0.2%| 107t alias | 3843 | 205 | 10159477423 | 1581960 | 10378573 | 29895061666317 | 108t retslot | 3843 | 205 | 10159477423 | 1581960 | 10378573 | 29895061666317 | 109t fre | 5399 +1556| 204 -1| 19869551210 +9710073787| 15236 -1566724| 10134542 -2.4%| 28699013248678 -4.0%| 110t mergephi | 5278 -121| 204 | 20025371186 +155819976| 15236 | 10134542 | 28699013248678 | 111t threadfull | 72831 +67553| 1224 +1020| 202402568370 +182377197184| 972775135 +972759899| 10206940 +0.7%| 28026521150697 -2.3%| 112t vrp | 70137 -2694| 1276 +52| 216458254352 +14055685982| 1014740538 +41965403| 10113204 -0.9%| 27883751110042 -0.5%| 113t dse | 70069 -68| 1275 -1| 216259198094 -199056258| 1014740522 -16| 9976103 -1.4%| 27259758460246 -2.2%| 114t dce | 68646 -1423| 1251 -24| 213766589405 -2492608689| 1010738219 -4002303| 9925029 -0.5%| 26929885571404 -1.2%| 115t stdarg | 68646 | 1251 | 213766589405 | 1010738219 | 9925029 | 26929885571404 | 116t cdce | 68646 | 1251 | 213766589405 | 1010738219 | 9925029 | 26929885571404 | 117t cselim | 68623 -23| 1251 | 213766434213 -155192| 1010738219 | 9922625 -0.0%| 26933160470828 +0.0%| 118t copyprop | 68236 -387| 1240 -11| 212518014812 -1248419401| 1003793990 -6944229| 9921476 -0.0%| 26931328243255 -0.0%| 119t ifcombine | 68132 -104| 1185 -55| 215021849380 +2503834568| 1175015399 +171221409| 9923593 +0.0%| 27111703655114 +0.7%| 120t mergephi | 60635 -7497| 1183 -2| 213958226983 -1063622397| 1170269374 -4746025| 9923593 | 27111703655114 | 121t phiopt | 60064 -571| 1168 -15| 213278698412 -679528571| 1169780184 -489190| 9887693 -0.4%| 27065894430626 -0.2%| 122t tailr | 60077 +13| 1168 | 213591827870 +313129458| 1169780184 | 9885590 -0.0%| 27029704150703 -0.1%| 123t ch | 61604 +1527| 1166 -2| 231773845670 +18182017800| 1169779155 -1029| 9923814 +0.4%| 27005048401494 -0.1%| 124t cplxlower | 61604 | 1166 | 231773845670 | 1169779155 | 9923814 | 27005048401494 | 125t sra | 61604 | 1166 | 231773845670 | 1169779155 | 9836640 -0.9%| 26380634193283 -2.3%| 126t thread | 68862 +7258| 1419 +253| 282837813276 +51063967606| 1884527067 +714747912| 9867464 +0.3%| 26288555069118 -0.3%| 127t dom | 73213 +4351| 1439 +20| 289296055849 +6458242573| 1881062486 -3464580| 9851389 -0.2%| 25915894360837 -1.4%| 128t copyprop | 72922 -291| 1437 -2| 288791521291 -504534558| 1880452325 -610161| 9848087 -0.0%| 25909920082474 -0.0%| 129t isolate-paths | 80793 +7871| 1437 | 289175243159 +383721868| 1887100849 +6648524| 9866571 +0.2%| 25908647817646 -0.0%| 130t reassoc | 81984 +1191| 1434 -3| 295644564738 +6469321579| 1886368237 -732612| 9879067 +0.1%| 25971893839783 +0.2%| 131t dce | 81377 -607| 1430 -4| 294937412703 -707152035| 1878493133 -7875104| 9801097 -0.8%| 25561486413957 -1.6%| 132t forwprop | 81666 +289| 1430 | 297646371403 +2708958700| 1878493133 | 9794576 -0.1%| 25528787255201 -0.1%| 133t phiopt | 81584 -82| 1430 | 297639291119 -7080284| 1878493133 | 9792840 -0.0%| 25528618873011 -0.0%| 134t ccp | 81588 +4| 1430 | 297550679459 -88611660| 1893125633 +14632500| 9791108 -0.0%| 25519558936471 -0.0%| 135t sincos | 81588 | 1430 | 297550679459 | 1893125633 | 9791108 | 25519558936471 | 136t bswap | 81588 | 1430 | 297550679459 | 1893125633 | 9791127 +0.0%| 25519558936471 | 137t laddress | 81588 | 1430 | 297550679459 | 1893125633 | 9793023 +0.0%| 25526884074520 +0.0%| 138t lim | 81648 +60| 1430 | 297859756610 +309077151| 1893125633 | 9794191 +0.0%| 25495948555139 -0.1%| 139t walloca | 81648 | 1430 | 297859756610 | 1893125633 | 9794191 | 25495948555139 | 140t pre | 80261 -1387| 1419 -11| 299154507133 +1294750523| 1885986610 -7139023| 9670301 -1.3%| 24860057746822 -2.5%| 141t sink | 80062 -199| 1416 -3| 299366883910 +212376777| 1855713098 -30273512| 9628335 -0.4%| 24691926355914 -0.7%| 145t dse | 80062 | 1416 | 299366883910 | 1855713098 | 9621313 -0.1%| 24673080303541 -0.1%| 146t dce | 79991 -71| 1416 | 299440495723 +73611813| 1855713098 | 9620600 -0.0%| 24670512443377 -0.0%| 147t fix_loops | 79991 | 1416 | 299440495723 | 1855713098 | 9620600 | 24670512443377 | 148t loop | 79991 | 1416 | 299440495723 | 1855713098 | 9620600 | 24670512443377 | 149t loopinit | 79991 | 1416 | 299440495723 | 1855713098 | 9620596 -0.0%| 24670508570371 -0.0%| 150t unswitch | 80230 +239| 1416 | 301091048942 +1650553219| 1855713098 | 9621927 +0.0%| 24664900640767 -0.0%| 151t sccp | 80229 -1| 1416 | 301090909602 -139340| 1855713098 | 9627674 +0.1%| 24665669129556 +0.0%| 152t lsplit | 80275 +46| 1416 | 301901055378 +810145776| 1855713098 | 9628013 +0.0%| 24669151374922 +0.0%| 153t lversion | 80275 | 1416 | 301901055378 | 1855713098 | 9628013 | 24669151374922 | 154t unrolljam | 80275 | 1416 | 301901055378 | 1855713098 | 9628013 | 24669151374922 | 155t cddce | 96307 +16032| 1405 -11| 400398657031 +98497601653| 1723477545 -132235553| 9615375 -0.1%| 24551469098820 -0.5%| 156t ivcanon | 96308 +1| 1405 | 400399330048 +673017| 1723477545 | 9617912 +0.0%| 24609543607312 +0.2%| 157t ldist | 96261 -47| 1530 +125| 396226006072 -4173323976| 2013657886 +290180341| 9617858 -0.0%| 24560695230994 -0.2%| 158t linterchange | 96261 | 1530 | 396226006072 | 2013657886 | 9617858 | 24560695230994 | 159t copyprop | 96263 +2| 1530 | 396225913851 -92221| 2013657886 | 9617599 -0.0%| 24560616860061 -0.0%| 166t ompexpssa | 96263 | 1530 | 396225913851 | 2013657886 | 9617599 | 24560616860061 | 167t ch_vect | 97304 +1041| 1530 | 396265259912 +39346061| 2013657886 | 9617920 +0.0%| 24560139310683 -0.0%| 168t ifcvt | 97464 +160| 1738 +208| 399080908207 +2815648295| 3365644947 +1351987061| 9621367 +0.0%| 24646895835295 +0.4%| 169t vect | 97302 -162| 1530 -208| 395362097676 -3718810531| 2013657886 -1351987061| 9620671 -0.0%| 24574578374634 -0.3%| 170t dce | 97284 -18| 1530 | 395133116739 -228980937| 2013657886 | 9619530 -0.0%| 24561056957484 -0.1%| 171t pcom | 97284 | 1530 | 395133116739 | 2013657886 | 9619527 -0.0%| 24560026676163 -0.0%| 172t cunroll | 109977 +12693| 1636 +106| 478680255671 +83547138932| 1999297268 -14360618| 9849220 +2.4%| 24167289537557 -1.6%| 173t fre | 109849 -128| 1636 | 478355091001 -325164670| 1999297268 | 9823426 -0.3%| 24002006012531 -0.7%| 174t dse | 109849 | 1636 | 478355091001 | 1999297268 | 9822112 -0.0%| 23986782125423 -0.1%| 175t slp | 109849 | 1636 | 478355091001 | 1999297268 | 9748052 -0.8%| 23841228691052 -0.6%| 177t ivopts | 109849 | 1636 | 478355091001 | 1999297268 | 9754436 +0.1%| 23818230835963 -0.1%| 178t lim | 109849 | 1636 | 478355091001 | 1999297268 | 9754536 +0.0%| 23818105695337 -0.0%| 179t loopdone | 109726 -123| 1636 | 478267981458 -87109543| 1999297268 | 9754508 -0.0%| 23818061294635 -0.0%| 180t no_loop | 109726 | 1636 | 478267981458 | 1999297268 | 9754508 | 23818061294635 | 181t slp | 109726 | 1636 | 478267981458 | 1999297268 | 9718223 -0.4%| 23804224391421 -0.1%| 183t veclower2 | 109575 -151| 1635 -1| 477128368553 -1139612905| 1999297226 -42| 9717499 -0.0%| 23803951872403 -0.0%| 184t switchlower | 216380 +106805| 1431 -204| 1380672969073 +903544600520| 1921470715 -77826511| 9714676 -0.0%| 25128620292826 +5.6%| 186t reassoc | 215688 -692| 1430 -1| 1380025901003 -647068070| 1921462330 -8385| 9725168 +0.1%| 25170465801635 +0.2%| 187t slsr | 215688 | 1430 | 1380025901003 | 1921462330 | 9725790 +0.0%| 25171051075791 +0.0%| 188t split-paths | 215690 +2| 1430 | 1380032502398 +6601395| 1921462330 | 9727714 +0.0%| 25171051342158 +0.0%| 189t tracer | 217826 +2136| 1458 +28| 1272463552867 -107568949531| 1909758769 -11703561| 9892396 +1.7%| 25179157448987 +0.0%| 190t fre | 218023 +197| 1456 -2| 1291101339405 +18637786538| 1905694277 -4064492| 9860835 -0.3%| 25066769644895 -0.4%| 191t thread | 224304 +6281| 2113 +657| 1260887440991 -30213898414| 3227986771 +1322292493| 9890836 +0.3%| 24869097162860 -0.8%| 192t dom | 231623 +7319| 2120 +7| 1265636026287 +4748585296| 3398605099 +170618329| 9891998 +0.0%| 24698836238947 -0.7%| 193t strlen | 231623 | 2120 | 1265636026287 | 3398605099 | 9883223 -0.1%| 24694963594820 -0.0%| 194t threadfull | 233644 +2021| 2218 +98| 1273228200834 +7592174547| 3495419473 +96814373| 9906384 +0.2%| 24638117243328 -0.2%| 195t vrp | 232054 -1590| 2294 +76| 1273076379738 -151821096| 4379683658 +884264185| 9878349 -0.3%| 24562986138635 -0.3%| 196t ccp | 231564 -490| 2289 -5| 1272303409980 -772969758| 4385826012 +6142354| 9877293 -0.0%| 24560983756866 -0.0%| 197t wrestrict | 231564 | 2289 | 1272303409980 | 4385826012 | 9877293 | 24560983756866 | 198t dse | 230745 -819| 2288 -1| 1272023199564 -280210416| 4385816013 -9999| 9810886 -0.7%| 24365376510779 -0.8%| 199t cddce | 241010 +10265| 2282 -6| 1369149644581 +97126445017| 4385012766 -803247| 9806927 -0.0%| 24352303495462 -0.1%| 200t forwprop | 241128 +118| 2277 -5| 1369582809624 +433165043| 4380754912 -4257854| 9788180 -0.2%| 24150309614008 -0.8%| 201t phiopt | 240767 -361| 2276 -1| 1369413694596 -169115028| 4371615103 -9139809| 9787199 -0.0%| 24147022235622 -0.0%| 202t fab | 238774 -1993| 2273 -3| 1356127299769 -13286394827| 4359973464 -11641639| 9776342 -0.1%| 24120633180272 -0.1%| 203t widening_mul | 238774 | 2273 | 1356127299769 | 4359973464 | 9774585 -0.0%| 24117914735934 -0.0%| 204t sink | 237049 -1725| 2271 -2| 1352510559484 -3616740285| 4359971169 -2295| 9763920 -0.1%| 24054869732314 -0.3%| 205t store-merging | 237049 | 2271 | 1352510559484 | 4359971169 | 9758244 -0.1%| 24015252481346 -0.2%| 206t tailc | 237045 -4| 2271 | 1352494254576 -16304908| 4359971169 | 9758192 -0.0%| 24015192437586 -0.0%| 207t dce | 235783 -1262| 2270 -1| 1350206240191 -2288014385| 4359971169 | 9751280 -0.1%| 23996865950908 -0.1%| 208t crited | 235783 | 2270 | 1350206240191 | 4359971169 | 9751280 | 23996865950908 | 209t uninit | 235783 | 2270 | 1350206240191 | 4359971169 | 9751280 | 23996865950908 | 210t local-pure-const | 235783 | 2270 | 1350349863074 +143622883| 4359971169 | 9751280 | 23997783661558 +0.0%| 211t modref | 235783 | 2270 | 1350349863074 | 4359971169 | 9751280 | 23997783661558 | 212t uncprop | 235783 | 2270 | 1350349863074 | 4359971169 | 9751280 | 23997783661558 | 246t nrv | 235783 | 2270 | 1350349863074 | 4359971169 | 9751272 -0.0%| 23997783661558 | 247t isel | 235783 | 2270 | 1350349863074 | 4359971169 | 9751262 -0.0%| 23997641911017 -0.0%| 250t optimized | 230075 -5708| 2265 -5| 1350486491782 +136628708| 4380125028 +20153859| 9751194 -0.0%| 24087942045836 +0.4%| 251t waccess | 230075 | 2265 | 1350486491782 | 4380125028 | 9751194 | 24087942045836 | 252r expand | 219555 -10520| 1914 -351| 1300300159576 -50186332206| 3055506535 -1324618492|-------------------|--------------------------| 253r vregs | 219555 | 1914 | 1300300159576 | 3055506535 | 65793993 +0.0%| 158587648130835 | 254r into_cfglayout | 215752 -3803| 1822 -92| 1300334045064 +33885488| 2856914371 -198592164| 65197156 -0.9%| 157473684195974 -0.7%| 255r jump | 215998 +246| 1826 +4| 1300487250854 +153205790| 2856927565 +13194| 65074406 -0.2%| 157201185251199 -0.2%| 256r subreg1 | 215998 | 1826 | 1300487250854 | 2856927565 | 64661258 -0.6%| 156980226244131 -0.1%| 257r dfinit | 215998 | 1826 | 1300487250854 | 2856927565 | 64661258 | 156980226244131 | 258r cse1 | 215922 -76| 1823 -3| 1300444468450 -42782404| 2856913789 -13776| 63667797 -1.5%| 156707311344200 -0.2%| 259r fwprop1 | 215922 | 1823 | 1300444468450 | 2856913789 | 59414712 -6.7%| 151499311612714 -3.3%| 260r cprop | 217389 +1467| 1818 -5| 1302497316424 +2052847974| 2840122245 -16791544| 59226283 -0.3%| 150812689195162 -0.5%| 261r rtl pre | 217389 | 1818 | 1302497316424 | 2840122245 | 59622715 +0.7%| 151863962265772 +0.7%| 262r hoist | 217389 | 1818 | 1302497316424 | 2840122245 | 59755680 +0.2%| 151863967787842 +0.0%| 263r cprop | 217370 -19| 1817 -1| 1301012893039 -1484423385| 2839953333 -168912| 58928550 -1.4%| 150419774693093 -1.0%| 265r cse_local | 217370 | 1817 | 1301012893039 | 2839953333 | 58809547 -0.2%| 149902126430912 -0.3%| 266r ce1 | 216528 -842| 1693 -124| 1297874035422 -3138857617| 2805149089 -34804244| 58601053 -0.4%| 149864991761443 -0.0%| 267r reginfo | 216528 | 1693 | 1297874035422 | 2805149089 | 58601053 | 149864991761443 | 268r loop2 | 216528 | 1693 | 1297874035422 | 2805149089 | 58601053 | 149864991761443 | 269r loop2_init | 216528 | 1693 | 1297874035422 | 2805149089 | 58601053 | 149864991761443 | 270r loop2_invariant | 216528 | 1693 | 1297874035422 | 2805149089 | 58809979 +0.4%| 150765280729437 +0.6%| 271r loop2_unroll | 218657 +2129| 1693 | 1311747865069 +13873829647| 2805149089 | 59303324 +0.8%| 150013522697100 -0.5%| 273r loop2_done | 218275 -382| 1693 | 1317456278918 +5708413849| 2805149089 | 59303220 -0.0%| 150013718008790 +0.0%| 276r cprop | 219309 +1034| 1693 | 1334139229371 +16682950453| 2805149089 | 59015017 -0.5%| 148960435540453 -0.7%| 277r stv | 219309 | 1693 | 1334139229371 | 2805149089 | 59016692 +0.0%| 148964638599813 +0.0%| 278r cse2 | 219303 -6| 1693 | 1334078649228 -60580143| 2805149089 | 58832341 -0.3%| 148449045444312 -0.3%| 279r dse1 | 219303 | 1693 | 1334078649228 | 2805149089 | 58860273 +0.0%| 148453707235147 +0.0%| 280r fwprop2 | 219272 -31| 1693 | 1333290149948 -788499280| 2805149089 | 58835261 -0.0%| 148462300686089 +0.0%| 282r init-regs | 219272 | 1693 | 1333290149948 | 2805149089 | 58926009 +0.2%| 148510272881097 +0.0%| 283r ud_dce | 219272 | 1693 | 1333290149948 | 2805149089 | 58889468 -0.1%| 148335390497275 -0.1%| 284r combine | 219352 +80| 1693 | 1333648234805 +358084857| 2805149089 | 58543412 -0.6%| 144713034986525 -2.4%| 286r stv | 219352 | 1693 | 1333648234805 | 2805149089 | 58543412 | 144713034986525 | 287r ce2 | 219261 -91| 1692 -1| 1333465104885 -183129920| 2804833682 -315407| 58542853 -0.0%| 144717376160885 +0.0%| 288r jump_after_combine | 220292 +1031| 1711 +19| 1334075792643 +610687758| 2813150500 +8316818| 58542297 -0.0%| 144708534014247 -0.0%| 289r bbpart | 220256 -36| 1706 -5| 1333936023873 -139768770| 2813142257 -8243| 58642109 +0.2%| 144695771569291 -0.0%| 290r outof_cfglayout | 220256 | 1706 | 1333936023873 | 2813142257 | 59149195 +0.9%| 145394559874685 +0.5%| 291r split1 | 220256 | 1706 | 1333936023873 | 2813142257 | 59197386 +0.1%| 145473058739988 +0.1%| 292r subreg3 | 220256 | 1706 | 1333936023873 | 2813142257 | 59251600 +0.1%| 145488031064603 +0.0%| 294r mode_sw | 220256 | 1706 | 1333936023873 | 2813142257 | 59251600 | 145488031064603 | 295r asmcons | 220256 | 1706 | 1333936023873 | 2813142257 | 59251600 | 145488031064603 | 300r ira | 220256 | 1706 | 1333936023873 | 2813142257 | 61492017 +3.8%| 148246220021068 +1.9%| 301r reload | 220045 -211| 1705 -1| 1334581013551 +644989678| 2812625999 -516259| 57379814 -6.7%| 146213679526534 -1.4%| 303r postreload | 220045 | 1705 | 1334581013551 | 2812625999 | 57248415 -0.2%| 146114585033173 -0.1%| 304r gcse2 | 220045 | 1705 | 1334581013551 | 2812625999 | 57248443 +0.0%| 146087407924926 -0.0%| 305r split2 | 220045 | 1705 | 1334581013551 | 2812625999 | 57519980 +0.5%| 146648496543144 +0.4%| 306r ree | 220045 | 1705 | 1334581013551 | 2812625999 | 57550983 +0.1%| 146968013482552 +0.2%| 307r cmpelim | 220045 | 1705 | 1334581013551 | 2812625999 | 57507638 -0.1%| 146861143961269 -0.1%| 308r pro_and_epilogue | 225303 +5258| 1709 +4| 1341177127695 +6596114144| 2812611798 -14201| 62704987 +9.0%| 162807859528298 +10.9%| 309r dse2 | 225303 | 1709 | 1341177127695 | 2812611798 | 62701751 -0.0%| 162807307011532 -0.0%| 310r csa | 225303 | 1709 | 1341177127695 | 2812611798 | 62685811 -0.0%| 162802974126976 -0.0%| 311r jump2 | 222011 -3292| 1700 -9| 1394955038853 +53777911158| 2811994770 -617028| 60591817 -3.3%| 162863551117381 +0.0%| 312r compgotos | 222011 | 1700 | 1394955038853 | 2811994770 | 60591817 | 162863551117381 | 314r peephole2 | 222011 | 1700 | 1394955038853 | 2811994770 | 61026320 +0.7%| 163016193759849 +0.1%| 315r ce3 | 221879 -132| 1700 | 1394975083423 +20044570| 2811994770 | 61000932 -0.0%| 163078660082367 +0.0%| 317r cprop_hardreg | 221879 | 1700 | 1394975083423 | 2811994770 | 60690862 -0.5%| 162902791239877 -0.1%| 318r rtl_dce | 221879 | 1700 | 1394975083423 | 2811994770 | 60674443 -0.0%| 162847446231467 -0.0%| 319r bbro | 217835 -4044| 1700 | 1358424822396 -36550261027| 2811994765 -5| 60592640 -0.1%| 162149759759118 -0.4%| 320r split3 | 217835 | 1700 | 1358424822396 | 2811994765 | 60593602 +0.0%| 162150528280896 +0.0%| 321r sched2 | 217835 | 1700 | 1358424822396 | 2811994765 | 60598064 +0.0%| 162181461863043 +0.0%| 323r stack | 217835 | 1700 | 1358424822396 | 2811994765 | 60598064 | 162181461863043 | 324r zero_call_used_regs | 217835 | 1700 | 1358424822396 | 2811994765 | 60598064 | 162181461863043 | 325r alignments | 217835 | 1700 | 1358424822396 | 2811994765 | 60598064 | 162181461863043 |
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
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.
jump threading one was filed a long time ago as PR 25623.
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.
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?
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.
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.
(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.
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.
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
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.
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.
I came across the following testcase (reduced from gcc/testsuite/g++.dg/torture/pr116902.C) which shows profile mismatches starting in jump threading: $ cat t.cc unsigned a; long i_d; void i(char c[][4]) { for (char e; e; e += ~0) for (bool h = 0; h < bool(i_d); h = 1) a = c[2][1] - c[2][2]; } I see: $ ./xgcc -B . -c t.cc -O2 -S -o /dev/null -fdump-tree-threadfull1-blocks-details=- | grep -B 1 "Invalid sum" ;; basic block 3, loop depth 1, count 955630224 (estimated locally, freq 65.4628), maybe hot ;; Invalid sum of incoming counts 114571471 (estimated locally, freq 7.8484), should be 955630224 (estimated locally, freq 65.4628) -- ;; basic block 5, loop depth 1, count 118111600 (estimated locally, freq 8.0909), maybe hot ;; Invalid sum of incoming counts 959170353 (estimated locally, freq 65.7053), should be 118111600 (estimated locally, freq 8.0909) where the profile was at least consistent in the previous pass: $ ./xgcc -B . -c t.cc -O2 -S -o /dev/null -fdump-tree-mergephi2-blocks-details=- | grep -B 1 "Invalid sum" looking at the jump threading dump I see: > Jump threading proved that the probability of edge 4->5 was originally estimated too small. (it is 11.0% (guessed) should be 89.0% (guessed)) which suggests that jump threading is just exposing a problem in the profile that was introduced earlier, but didn't manifest as an inconsistent profile.
>cddce is also very high That was partly fixed with r14-2101-gc2ebccc97190a9 but it was still wrong. I have a full fix.
Created attachment 63023 [details] Another jump threading case Reduced from gimple-ssa-nonnull-compare.cc. On bb to the call to a we get: ;; Invalid sum of incoming counts 751619280 (estimated locally, freq 0.7000), should be 864362171 (estimated locally, freq 0.8050)
Created attachment 63025 [details] unconditional tail call with a call afterwards profile_estimate gets this right away: ``` ;; Invalid sum of incoming counts 1073741824 (estimated locally, freq 1.0000), should be 966367642 (estimated locally, freq 0.9000) ``` What is odd we (LLVM does not either) figure out this is just an infinite loop.
Created attachment 63026 [details] fnsplit/inlining causes invalid count Compile this at `-O2 -fno-exceptions` and you get in inline: ``` ;; Invalid sum of incoming counts 233216728 (estimated locally, freq 0.2172), should be 153923040 (estimated locally, freq 0.1434) ``` if we turn off partial inlining (-fno-partial-inlining), it does not show up.
(In reply to Andrew Pinski from comment #16) > Created attachment 63025 [details] > unconditional tail call with a call afterwards > > profile_estimate gets this right away: > ``` > ;; Invalid sum of incoming counts 1073741824 (estimated locally, freq > 1.0000), should be 966367642 (estimated locally, freq 0.9000) > ``` This shows up in assign_dfs_numbers in dominance.ii.
> > profile_estimate gets this right away: > ``` > ;; Invalid sum of incoming counts 1073741824 (estimated locally, freq > 1.0000), should be 966367642 (estimated locally, freq 0.9000) > ``` > > What is odd we (LLVM does not either) figure out this is just an infinite loop. There is no really right way to represent profile of infinite loop unless you drop everything else to 0. So mismatches on the entry BB of infinite loop are OK.. Honza
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>: https://gcc.gnu.org/g:9f27ac9b83af5e01098481d4a776fabb53f63618 commit r16-6069-g9f27ac9b83af5e01098481d4a776fabb53f63618 Author: Andrew Pinski <andrew.pinski@oss.qualcomm.com> Date: Mon Dec 8 22:53:06 2025 -0800 cfg: Fix count when creating new forwarder block This was a bug previously but maybe did't matter as most of the time the block was going to be removed after cddce. Anyways the problem here is the count of the new bb was missing of the first edge that was moved to it. So the fix is reuse the count after the splitting of the edge as the initial value instead of 0. This does not fix gcc.target/i386/pr90178.c with -m32, but at least we don't get any more warning saying the incorrect count happening. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: PR tree-optimization/103680 * tree-cfg.cc (make_forwarders_with_degenerate_phis): Fix initial value of the count to new bb. Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>: https://gcc.gnu.org/g:ca6e6d317ca245682e8f06e3bb7cd6a76ffd0357 commit r16-6070-gca6e6d317ca245682e8f06e3bb7cd6a76ffd0357 Author: Andrew Pinski <andrew.pinski@oss.qualcomm.com> Date: Tue Dec 9 01:09:53 2025 -0800 ldist: Fix probability on loop exit While moving the phi part of removal of forwarder blocks, I noticed that I was getting some failures due to "mismatch counts". I worked around the issue by disabling the case where the forwarder block would just get merged. I have now gone back and found the problem is in ldist where it is removing the loop by changing the exit to always exit but forgot to update the edge to always probability. This fixes that and also removes a few of the "mismatch counts". Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: PR tree-optimization/103680 * tree-loop-distribution.cc (destroy_loop): Set probability of the exit edge to be always. Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>