From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4C9EF3858416; Sat, 1 Jul 2023 07:11:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C9EF3858416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688195496; bh=H9/klZlEYqTbh4ccoy52fBBj7c61FoB9YL3HouOh5Lo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m3eGw+ScGIrpmEkCpfNd7o49JRCnK/JPEqYcI0MMrH6+WSxw2lcYmacCL+FjHl/Fa o1r4932FZ7isW7d2IPi8ka04i9leW5g/hGpL+wCsfxDBJGoCmnpebnbPiAkBS5jS38 4yjilgZEs+bxS83anVqpi/t+czHW/8MVsVgDHwSU= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103680] Jump threading and switch corrupts profile Date: Sat, 01 Jul 2023 07:11:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: internal-improvement, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103680 --- Comment #12 from CVS Commits --- The master branch has been updated by Jan Hubicka : https://gcc.gnu.org/g:02460c0b8c9000359a09440f9532664a7835f158 commit r14-2228-g02460c0b8c9000359a09440f9532664a7835f158 Author: Jan Hubicka 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 n= eeds to determine probability of the duplicated path and redistribute probablit= ies. For some reaosn however the conditonal probability of redirected path is computed after its counts is subtracted which is wrong and often result= s in probability greater than 100%. I also fixed error mesage. Compilling tramp3d I now get following pass= es 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 +347194= 302 130t thread | 313 +6| 347221478 +27= 176 131t dom | 321 +8| 346841121 -380= 357 134t reassoc | 323 +2| 346841121 136t forwprop | 327 +4| 347026371 +185= 250 144t pre | 326 -1| 347040926 +14= 555 172t ifcvt | 338 +2| 347218249 +156= 280 173t vect | 409 +71| 356357418 +9139= 169 176t cunroll | 377 -32| 126071925 -230285= 493 183t loopdone | 376 -1| 126015489 -56= 436 194t tracer | 379 +3| 127258199 +1242= 710 197t dom | 375 -4| 128352165 +1093= 966 199t threadfull | 379 +4| 128526112 +173= 947 200t vrp | 381 +2| 128724673 +198= 561 204t dce | 374 -7| 128632495 -92= 178 206t sink | 370 -4| 128618043 -14= 452 211t cddce | 372 +2| 128632495 +14= 452 248t ehcleanup | 370 -2| 128618755 -13= 740 255t optimized | 362 -8| 128576810 -41= 945 256r expand | 356 -6| 128899768 +322= 958 258r into_cfglayout | 353 -3| 129051765 +151= 997 259r jump | 354 +1| 129051765 262r cse1 | 353 -1| 129051765 275r loop2_unroll | 355 +2| 132182110 +3130= 345 277r loop2_done | 354 -1| 132182109 = -1 312r pro_and_epilogue | 371 +17| 132222324 +40= 215 323r bbro | 375 +4| 132095926 -126= 398 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.=