From patchwork Thu Sep 6 04:10:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 182002 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 5E22F2C0094 for ; Thu, 6 Sep 2012 14:11:15 +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=1347509476; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=v7iTp2p bPiLr5joFPHiGMO9kMOQ=; b=akpmmQqpoAXOYNUNcDujbRj/yBHo4QBXCVKPgtN h21tu18SCYUQbP6gAjgWteWM4TTa68ZOOJW7ZQur/2Ed684WBe13YhWXOiE53Jno J+Tfj6qfAlXZg86wst2o+AtFJ7gZix/sEkjanJYoP7PqSB4AcUoXmswwnj24zfM8 WZlo= 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:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=awaQVqUtUlvpNDFwu36qmPmLxES13xRzxaq2PXpEwJ2+LrHT6Ry7Y0JhiVnOwo IhJIsAlK2GG652dDEWns76Ih0sQavcOf5cvnT8TlStm1bIZ8OR/LrXjJ28+lXXZw fA9ArwhXYMPPMboQdmGBm4aaT786Y5g7g+scBy8iPIQZs=; Received: (qmail 6356 invoked by alias); 6 Sep 2012 04:11:10 -0000 Received: (qmail 5429 invoked by uid 22791); 6 Sep 2012 04:11:07 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-wg0-f41.google.com (HELO mail-wg0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 06 Sep 2012 04:10:54 +0000 Received: by wgbds1 with SMTP id ds1so4647260wgb.2 for ; Wed, 05 Sep 2012 21:10:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.131.196 with SMTP id m46mr508585wei.35.1346904653584; Wed, 05 Sep 2012 21:10:53 -0700 (PDT) Received: by 10.216.2.4 with HTTP; Wed, 5 Sep 2012 21:10:53 -0700 (PDT) Date: Wed, 5 Sep 2012 21:10:53 -0700 Message-ID: Subject: [PATCH] Fix PR 54494, removal of volatile store in strlen optimization because of the inlininer From: Andrew Pinski To: GCC Patches , Jan Hubicka 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, The inlininer likes to recreate some MEM_REF, it copies most of the bits (TREE_THIS_NOTRAP, TREE_THIS_VOLATILE, etc.) but forgets about TREE_SIDE_EFFECTS. This causes the strlen optimization to think the memory store does not have a side effects. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Thanks, Andrew Pinski ChangeLog: * tree-inline.c (remap_gimple_op_r): Copy TREE_SIDE_EFFECTS also. testsuite/ChangeLog: * gcc.dg/tree-ssa/strlen-1.c: New testcase. Index: testsuite/gcc.c-torture/compile/pr49474.c =================================================================== --- testsuite/gcc.c-torture/compile/pr49474.c (revision 0) +++ testsuite/gcc.c-torture/compile/pr49474.c (revision 0) @@ -0,0 +1,16 @@ +typedef struct gfc_formal_arglist +{ + int next; +} +gfc_actual_arglist; +update_arglist_pass (gfc_actual_arglist* lst, int po, unsigned argpos, + const char *name) +{ + ((void)(__builtin_expect(!(argpos > 0), 0) ? __builtin_unreachable(), 0 : 0)); + if (argpos == 1) + return 0; + if (lst) + lst->next = update_arglist_pass (lst->next, po, argpos - 1, name); + else + lst = update_arglist_pass (((void *)0), po, argpos - 1, name); +} Index: cprop.c =================================================================== --- cprop.c (revision 176187) +++ cprop.c (working copy) @@ -1332,7 +1332,7 @@ find_implicit_sets (void) FOR_EACH_BB (bb) { /* Check for more than one successor. */ - if (! EDGE_COUNT (bb->succs) > 1) + if (EDGE_COUNT (bb->succs) <= 1) continue; cond = fis_get_condition (BB_END (bb));