From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id EAAEC3857C74; Wed, 7 Oct 2020 10:34:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAAEC3857C74 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/PR97295-profile-merging)] IPA: merge profiles more sensitively X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/PR97295-profile-merging X-Git-Oldrev: ebc77ce3a4c70730b4e38d68f88693eadbdc8712 X-Git-Newrev: cfe107c647fc6703f98602a70339f0514da39726 Message-Id: <20201007103406.EAAEC3857C74@sourceware.org> Date: Wed, 7 Oct 2020 10:34:06 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Oct 2020 10:34:07 -0000 https://gcc.gnu.org/g:cfe107c647fc6703f98602a70339f0514da39726 commit cfe107c647fc6703f98602a70339f0514da39726 Author: Martin Liska Date: Wed Oct 7 12:30:27 2020 +0200 IPA: merge profiles more sensitively During WPA we merge 2 functions where one is built with -O3 -fprofile-use while the other one uses -O0. We end up with: prevailing node: BitwiseCast (const double aFrom) { long unsigned int temp; long unsigned int D.4528; : BitwiseCast (aFrom_2(D), &temp); _4 = temp; temp ={v} {CLOBBER}; : : return _4; } merged node: BitwiseCast (const double aFrom) { [count: 1509]: _3 = VIEW_CONVERT_EXPR(aFrom_2(D)); return _3; } What happens is that we copy dst->count = src->count.ipa() but we skip merging of BBs (a different CFG). Then we end up in situation where profile of a ENTRY_BB_FOR_FN == uninitialized while dst->count.quality is precise. gcc/ChangeLog: PR ipa/97295 * ipa-utils.c (ipa_merge_profiles): Diff: --- gcc/ipa-utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c index 23e7f714306..fe2149069be 100644 --- a/gcc/ipa-utils.c +++ b/gcc/ipa-utils.c @@ -437,10 +437,7 @@ ipa_merge_profiles (struct cgraph_node *dst, else if (dst->count.ipa ().initialized_p ()) ; else if (src->count.ipa ().initialized_p ()) - { - copy_counts = true; - dst->count = src->count.ipa (); - } + copy_counts = true; /* If no updating needed return early. */ if (dst->count == orig_count) @@ -620,6 +617,9 @@ ipa_merge_profiles (struct cgraph_node *dst, bool dstscale = !copy_counts && dstnum.initialized_p () && !(dstnum == dstden); + if (copy_counts) + dst->count = src->count.ipa (); + /* TODO: merge also statement histograms. */ FOR_ALL_BB_FN (srcbb, srccfun) {