]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix epilogue loop profile
authorJan Hubicka <jh@suse.cz>
Fri, 7 Jul 2023 16:22:11 +0000 (18:22 +0200)
committerJan Hubicka <jh@suse.cz>
Fri, 7 Jul 2023 16:22:11 +0000 (18:22 +0200)
commit5966349aa7e1fcbee2558f996b2484b433a0fcf4
treeb070421927266061c8af77209a32473690340a77
parent6f428f1a88557f8b5df653ece92ac3e7b5baf6c6
Fix epilogue loop profile

Fix two bugs in scale_loop_profile which crept in during my
cleanups and curiously enoug did not show on the testcases we have so far.
The patch also adds the missing call to cap iteration count of the vectorized
loop epilogues.

Vectorizer profile needs more work, but I am trying to chase out obvious bugs first
so the profile quality statistics become meaningful and we can try to improve on them.

Now we get:

Pass dump id and name            |static mismatcdynamic mismatch
                                 |in count     |in count
107t cunrolli                    |      3    +3|        17251       +17251
116t vrp                         |      5    +2|        30908       +16532
118t dce                         |      3    -2|        17251       -13657
127t ch                          |     13   +10|        17251
131t dom                         |     39   +26|        17251
133t isolate-paths               |     47    +8|        17251
134t reassoc                     |     49    +2|        17251
136t forwprop                    |     53    +4|       202501      +185250
159t cddce                       |     61    +8|       216211       +13710
161t ldist                       |     62    +1|       216211
172t ifcvt                       |     66    +4|       373711      +157500
173t vect                        |    143   +77|      9801947     +9428236
176t cunroll                     |    149    +6|     12006408     +2204461
183t loopdone                    |    146    -3|     11944469       -61939
195t fre                         |    142    -4|     11944469
197t dom                         |    141    -1|     13038435     +1093966
199t threadfull                  |    143    +2|     13246410      +207975
200t vrp                         |    145    +2|     13444579      +198169
204t dce                         |    143    -2|     13371315       -73264
206t sink                        |    141    -2|     13371315
211t cddce                       |    147    +6|     13372755        +1440
255t optimized                   |    145    -2|     13372755
256r expand                      |    141    -4|     13371197        -1558
258r into_cfglayout              |    139    -2|     13371197
275r loop2_unroll                |    143    +4|     16792056     +3420859
291r ce2                         |    141    -2|     16811462
312r pro_and_epilogue            |    161   +20|     16873400       +61938
315r jump2                       |    167    +6|     20910158     +4036758
323r bbro                        |    160    -7|     16559844     -4350314

Vect still introduces 77 profile mismatches (same as without this patch)
however subsequent cunroll works much better with 6 new mismatches compared to
78.  Overall it reduces 229 mismatches to 160.

Also overall runtime estimate is now reduced by 6.9%.
Previously the overall runtime estimate grew by 11% which was result of the fat
that the epilogue profile was pretty much the same as profile of the original
loop.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

* cfgloopmanip.cc (scale_loop_profile): Fix computation of count_in and scaling blocks
after exit.
* tree-vect-loop-manip.cc (vect_do_peeling): Scale loop profile of the epilogue if bound
is known.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/vect-profile-upate.c: New test.
gcc/cfgloopmanip.cc
gcc/testsuite/gcc.dg/tree-ssa/vect-profile-upate.c [new file with mode: 0644]
gcc/tree-vect-loop-manip.cc