From patchwork Thu Aug 30 22:18:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 180876 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]) by ozlabs.org (Postfix) with SMTP id 1D5492C024D for ; Fri, 31 Aug 2012 08:19:17 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1346969958; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Cc:Subject:Message-ID:Mail-Followup-To:MIME-Version: Content-Type:Content-Disposition:User-Agent:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=74MZuoYG99aHLzUbtDsrBMAMhWM=; b=cdoSTBvZOiLW4cI5z7+GOydW5nCVyYmci08havZ9KFONJMhL7D+jIDVxKTpd17 61kLdMd0CIRDNKN5EQgrfd5HUIu028W5YMWSFMWD/n8Fo0caFknFnXi3/2mMwVnR K2DFJVe/Jeqt/Q/gO4RmX9TpNFnr2Zho4GC3MP7F5nNhg= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=RtrqfGbQztBXfOWw1+LSNlZZoFmf02GJLcKR3AsGocQuLOmbqmEqnrckJZ1Jcu wC5QRsVL3BXsv817RVGfgGCGrZDT0gNv8loHq5gi4erLCMyb+2iA7QsPEam50TnV 7zKHJarCMebvXmnXMSLYIrzU+ZBt5fLdwlc6JQOrKgDfs=; Received: (qmail 19348 invoked by alias); 30 Aug 2012 22:19:13 -0000 Received: (qmail 19340 invoked by uid 22791); 30 Aug 2012 22:19:12 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Aug 2012 22:18:59 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 76F1DA3DDF; Fri, 31 Aug 2012 00:18:58 +0200 (CEST) Date: Fri, 31 Aug 2012 00:18:57 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH, PR 54409] Remapping inlining predicates fix Message-ID: <20120830221857.GE3395@virgil.arch.suse.de> Mail-Followup-To: GCC Patches , Jan Hubicka MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi, this patch fixes PR 54409. The condition for dealing with offset maps when remapping predicates which I have added recently was wrong, fortunately a subsequent assert caught this. We cannot shift stuff by an offset when it is passed by value. Conversely, the condition was unnecessarily restrictive, we can still happily use non-aggregate and by-value conditions when offset map is negative, that only means that by-ref stuff is not guaranteed to survive. Bootstrapped and tested on x86_64-linux. OK for trunk? Thanks, Martin 2012-08-30 Martin Jambor PR middle-end/54409 * ipa-inline-analysis.c (remap_predicate): Fix the offset_map checking condition. * gcc/testsuite/gcc.dg/torture/pr54409.c: New test. Index: src/gcc/ipa-inline-analysis.c =================================================================== --- src.orig/gcc/ipa-inline-analysis.c +++ src/gcc/ipa-inline-analysis.c @@ -2811,8 +2811,11 @@ remap_predicate (struct inline_summary * if (!operand_map || (int)VEC_length (int, operand_map) <= c->operand_num || VEC_index (int, operand_map, c->operand_num) == -1 - || (!c->agg_contents - && VEC_index (int, offset_map, c->operand_num) != 0) + /* TODO: For non-aggregate conditions, adding an offset is + basically an arithmetic jump function processing which + we should support in future. */ + || ((!c->agg_contents || !c->by_ref) + && VEC_index (int, offset_map, c->operand_num) > 0) || (c->agg_contents && c->by_ref && VEC_index (int, offset_map, c->operand_num) < 0)) cond_predicate = true_predicate (); Index: src/gcc/testsuite/gcc.dg/torture/pr54409.c =================================================================== --- /dev/null +++ src/gcc/testsuite/gcc.dg/torture/pr54409.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ + +int b; + +struct S +{ + char *p; + struct { + } s; + int a; +}; + +static _Bool +fn2 (int *p1) +{ + if (b) + { + struct S *c = (struct S *) &p1; + return c->a; + } +} + +_Bool +fn3 (struct S *p1) +{ + if (fn2 ((int *) &p1->s)) + return 0; +}