From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72164 invoked by alias); 22 Jun 2017 14:51:43 -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 72069 invoked by uid 89); 22 Jun 2017 14:51:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=shrink, quality X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Jun 2017 14:51:39 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id A053E5469C9; Thu, 22 Jun 2017 16:51:36 +0200 (CEST) Date: Thu, 22 Jun 2017 14:51:00 -0000 From: Jan Hubicka To: Andreas Schwab Cc: gcc-patches@gcc.gnu.org Subject: Re: Add quality tracking for profile counter Message-ID: <20170622145136.GB94431@kam.mff.cuni.cz> References: <20170619094949.GA49407@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2017-06/txt/msg01672.txt.bz2 Hi, I proofread the code and noticed that in some cases I may trigger division by 0 that may get different outputs depending on optimization setting on Itanium. This is what I comitted after profiledbootstrap and regtesting at x86_64. * profile-count.h (apply_probability, apply_scale, probability_in): Fix checks for zero. Index: profile-count.h =================================================================== --- profile-count.h (revision 249364) +++ profile-count.h (working copy) @@ -255,7 +255,7 @@ public: profile_count apply_probability (int prob) const { gcc_checking_assert (prob >= 0 && prob <= REG_BR_PROB_BASE); - if (*this == profile_count::zero ()) + if (m_val == 0) return *this; if (!initialized_p ()) return profile_count::uninitialized (); @@ -267,24 +267,25 @@ public: /* Return *THIS * NUM / DEN. */ profile_count apply_scale (int64_t num, int64_t den) const { - if (*this == profile_count::zero ()) + if (m_val == 0) return *this; if (!initialized_p ()) return profile_count::uninitialized (); profile_count ret; + gcc_checking_assert (num >= 0 && den > 0); /* FIXME: shrink wrapping violates this sanity check. */ - gcc_checking_assert ((num >= 0 - && (num <= REG_BR_PROB_BASE - || den <= REG_BR_PROB_BASE) - && den > 0) || 1); + gcc_checking_assert ((num <= REG_BR_PROB_BASE + || den <= REG_BR_PROB_BASE) || 1); ret.m_val = RDIV (m_val * num, den); ret.m_quality = MIN (m_quality, count_adjusted); return ret; } profile_count apply_scale (profile_count num, profile_count den) const { - if (*this == profile_count::zero () || num == profile_count::zero ()) - return profile_count::zero (); + if (m_val == 0) + return *this; + if (num.m_val == 0) + return num; if (!initialized_p () || !num.initialized_p () || !den.initialized_p ()) return profile_count::uninitialized (); gcc_checking_assert (den > 0); @@ -306,7 +307,7 @@ public: OVERALL. */ int probability_in (profile_count overall) { - if (*this == profile_count::zero ()) + if (!m_val) return 0; if (!initialized_p () || !overall.initialized_p ()) return REG_BR_PROB_BASE / 2;