From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 83138 invoked by alias); 31 Oct 2018 14:36:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 83085 invoked by uid 89); 31 Oct 2018 14:36:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Oct 2018 14:36:08 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD76730821EB; Wed, 31 Oct 2018 14:36:06 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-29.rdu2.redhat.com [10.10.112.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id D26A061B73; Wed, 31 Oct 2018 14:36:05 +0000 (UTC) Subject: Re: [PATCH AutoFDO/2]Treat ZERO as common profile probability/count To: "bin.cheng" , gcc-patches References: <7f153787-f390-4661-92aa-06d47cefbbf5.bin.cheng@linux.alibaba.com> From: Jeff Law Openpgp: preference=signencrypt Message-ID: Date: Wed, 31 Oct 2018 15:02:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <7f153787-f390-4661-92aa-06d47cefbbf5.bin.cheng@linux.alibaba.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg02041.txt.bz2 On 10/31/18 12:30 AM, bin.cheng wrote: > Hi, > In new profile probability/count infra, we have different precision quality categories, > and probabilities/counts of different categories are not supposed to be compared or > calculated. Though in general is an improvement, it introduces unexpected behavior. > Specifically, class profile_probablity and profile_count themselves are implemented > by comparing probabilities/counts against profile_count::zero(). while zero() is of > profile_precision category, it's always compared different to zero of other precision > categories including afdo. > > I can see two ways fixing this: 1) Treat zero as a common probability/count regardless > of its category; 2) Provide an "is_zero" method rather than relying on "==" comparison > against probability_count::zero(). 2) requires lots of code changes so I went with 1) > in this patch set. This patch doesn't handle "always" but it might be. > > This patch also corrects a minor issue where we try to invert an uninitialized value. > > Bootstrap and test on x86_64 in patch set. Is it OK? > > Thanks, > bin > > 2018-10-31 Bin Cheng > > * expmed.c (emit_store_flag_force): Use profile_probability::always. > * profile-count.h (profile_probability::always): Add parameter. > (profile_probability::operator==, profile_count::operator==): Treat > ZERO as common probability/count regardless of its quality. > (profile_probability::invert): Don't invert uninitialized probability. > I'm really not sure the emit_store_flag_force change is right -- essentially without external information I can't see how we can pass in any probability here other than "we don't know" which is profile_probability::uninitialized IIUC. You could potentially make an argument that a 50-50 probability is reasonable here. That's profile_probability::even. But I just don't see how profile_probability::always is right here. jeff