From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116716 invoked by alias); 11 May 2016 02:34:00 -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 116656 invoked by uid 89); 11 May 2016 02:33:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=states 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 11 May 2016 02:33:55 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 9DCC254574D; Wed, 11 May 2016 04:33:51 +0200 (CEST) Date: Wed, 11 May 2016 02:34:00 -0000 From: Jan Hubicka To: David Edelsohn Cc: Wilco Dijkstra , "segher@kernel.crashing.org" , Christophe Lyon , "gcc-patches@gcc.gnu.org" , nd , Jan Hubicka Subject: Re: [PATCH 3/3] shrink-wrap: Remove complicated simple_return manipulations Message-ID: <20160511023351.GA21844@kam.mff.cuni.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2016-05/txt/msg00774.txt.bz2 > >>>>> Wilco Dijkstra wrote: > > > It relies on static branch probabilities, which are set completely wrong in GCC, > so it ends up optimizing the hot path in many functions for size > rather than speed > and visa versa. > > This sounds like the static branch prediction issue that we have been > discussing with Honza. Honza discussed plans to improve this > infrastructure during this development cycle. In fact I just started on refactoring the profile updating code. However I do not see how it is going to help there or what is wrong. In the testcase: void g(void); int a; int f(void) { g(); if (a < 0x7ffffffe) // or != 0 or < 0 or a < 0x7ffffffe return -1; a = 1; return 1; } triggers negative return heuristics that says that with 96% probability the function will not return negative constant (as those are usually error states). This further combine with default compare heuristcs but it won't outvote this one to make return -1 more likely and return 1; With opcode, we predict that comparsions a==b are false when b is not 0. We also predict that values are positive. This is what triggers for test a>0 What is the particular problem with this? Honza > > - David