From patchwork Thu Feb 6 06:43:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 317367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BFF742C0096 for ; Thu, 6 Feb 2014 17:43:32 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=TtfyUH1+pTd3P/FQ8 9iHdWG0qCyMwV/IT+elK0YTJi24sHjveDNb3Bf1HwMsZm0CtVhO9XqTSYmGJQ6wU 4k1r78pvdin6j/OrxB5hPwWoyYPagNuk6xGs9yma4E+hbjKZ5yuMEJ38ovHibJfz ghQya+FCk/85QdTS99GKTdGB1c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=Qv2eSwVzIJNlcEMxYTKTDV9 SuDo=; b=QZhqgOqhNj+O1VZbqSubmNhSixz4PwhnB71hVqleIV8BtkHg6Lohn/k b9F2ckq0TE2tQllOHKBCp5+CmYavnZAXxAp1T4d9Jhmloku8cMqd8LR1JPuMYuiD AkLIAT0ZjZ29kbbMtP6XwEndArHl2kUg/Rc/QnkH7qgXWYTmlJKc= Received: (qmail 23658 invoked by alias); 6 Feb 2014 06:43:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 23644 invoked by uid 89); 6 Feb 2014 06:43:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD autolearn=ham version=3.3.2 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; Thu, 06 Feb 2014 06:43:21 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 02EC25410FF; Thu, 6 Feb 2014 07:43:17 +0100 (CET) Date: Thu, 6 Feb 2014 07:43:17 +0100 From: Jan Hubicka To: Jakub Jelinek Cc: Richard Biener , Jan Hubicka , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] One possible fix for the compute_bb_predicate oscillation (PR ipa/60013) Message-ID: <20140206064317.GA29096@kam.mff.cuni.cz> References: <20140205125130.GC12671@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140205125130.GC12671@tucnak.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Hi, this is variant of patch I am testing (thanks Jakub for the hard analysis). The dataflow was supposed to be monotonous by keeping the rule that oldvalue imply new value at each step. This is broken by the approximation done by and/or operations. Instead of dropping to true, it seems easier to simply or the result before updating. This operation should be no-op until we hit the clause limit. Bootstrapping/regtesting x86_64-linux, will commit if it passes. Honza * ipa-inline-analysis.c (compute_bb_predicates): Ensure monotonicity of the dataflow. gcc.dg/pr60013.c: New testcase. Index: ipa-inline-analysis.c =================================================================== --- ipa-inline-analysis.c (revision 207514) +++ ipa-inline-analysis.c (working copy) @@ -310,7 +310,7 @@ add_clause (conditions conditions, struc if (false_predicate_p (p)) return; - /* No one should be sily enough to add false into nontrivial clauses. */ + /* No one should be silly enough to add false into nontrivial clauses. */ gcc_checking_assert (!(clause & (1 << predicate_false_condition))); /* Look where to insert the clause. At the same time prune out @@ -1035,7 +1035,7 @@ inline_node_removal_hook (struct cgraph_ memset (info, 0, sizeof (inline_summary_t)); } -/* Remap predicate P of former function to be predicate of duplicated functoin. +/* Remap predicate P of former function to be predicate of duplicated function. POSSIBLE_TRUTHS is clause of possible truths in the duplicated node, INFO is inline summary of the duplicated node. */ @@ -1887,8 +1887,15 @@ compute_bb_predicates (struct cgraph_nod } else if (!predicates_equal_p (&p, (struct predicate *) bb->aux)) { - done = false; - *((struct predicate *) bb->aux) = p; + /* This OR operation is needed to ensure monotonous data flow + in the case we hit the limit on number of clauses and the + and/or operations above give approximate answers. */ + p = or_predicates (summary->conds, &p, (struct predicate *)bb->aux); + if (!predicates_equal_p (&p, (struct predicate *) bb->aux)) + { + done = false; + *((struct predicate *) bb->aux) = p; + } } } } Index: testsuite/gcc.dg/pr60013.c =================================================================== --- testsuite/gcc.dg/pr60013.c (revision 0) +++ testsuite/gcc.dg/pr60013.c (revision 0) @@ -0,0 +1,47 @@ +/* PR ipa/60013 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef long int jmp_buf[64]; +extern int _setjmp (jmp_buf) __attribute__ ((__nothrow__)); +struct S { int a, b, c; }; +extern struct S *baz (struct S *); +static jmp_buf j; + +static inline int +bar (int b, int d) +{ + return (b & d) < 0; +} + +struct S * +foo (int a, struct S *b, struct S *c, struct S *d) +{ + if (b->a == 0) + { + switch (a) + { + case 8: + return baz (b); + case 7: + bar (b->c, c->b); + return 0; + case 6: + case 5: + case 4: + return baz (c); + case 3: + case 2: + return baz (d); + } + return 0; + } + if (b->a == 1) + { + if (baz (c)) + return c; + else if (_setjmp (j)) + baz (b); + } + return 0; +}