public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix update_bb_profile_for_threading
@ 2023-07-01  7:13 Jan Hubicka
  0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2023-07-01  7:13 UTC (permalink / raw)
  To: gcc-patches

Hi,
this patch fixes some of profile mismatches 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.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes to be committed:
#	modified:   cfg.cc
#	modified:   testsuite/gcc.dg/tree-prof/cmpsf-1.c
#	new file:   testsuite/gcc.dg/tree-ssa/pr103680.c
#
# Changes not staged for commit:
#	modified:   internal-fn.def
#	modified:   ../libstdc++-v3/include/bits/c++config
#	modified:   ../libstdc++-v3/include/bits/new_allocator.h
#	modified:   ../libstdc++-v3/include/ext/malloc_allocator.h
#	modified:   ../libstdc++-v3/include/ext/random.tcc
#
# Untracked files:
#	../1
#	../alwaysexec
#	../b/
#	../buil3/
#	../build-in/
#	../build-inst/
#	../build-inst2/
#	../build-kub/
#	../build-lto/
#	../build-lto2/
#	../build-lto3/
#	../build-ppc/
#	../build-profiled/
#	../build/
#	../build2/
#	../build3/
#	../changes
#	.cfgloopmanip.cc.swo
#	.ipa-inline.cc.swo
#	.profile.c.swo
#	.tree-ssa-loop-ivcanon.cc.swn
#	.tree-ssa-loop-ivcanon.cc.swo
#	1
#	aa
#	alwaysexe
#	attachment.cgi?id=55110
#	attachment.cgi?id=55110&action=edit
#	blm
#	buffer
#	clanup
#	cleanup
#	cleanup2
#	cp/fnspec++
#	dd
#	dead
#	fix
#	fixp
#	fixp2
#	fixp3
#	fixup
#	fnf
#	fnspec++
#	fp
#	fwfix
#	inline-stability
#	ipastrict2
#	jh@alberti.arch.suse.cz
#	mm
#	mmm
#	mujpa
#	nnn
#	nou
#	patch-k
#	pp
#	ppp
#	rev
#	revertik
#	richi
#	rr
#	rrr
#	ryzen4
#	sracandidate
#	srap
#	testsuite/g++.dg/tree-ssa/kill.C.051t.modref1
#	testsuite/g++.dg/tree-ssa/kill.s
#	tree-ssa-loop-ch-old.cc
#	wget-log
#	../libstdc++-v3/include/rev
#	../libstdc++-v3/wake
#

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-01  7:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-01  7:13 Fix update_bb_profile_for_threading Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).