From patchwork Fri Apr 20 11:55:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 154030 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 9EB18B704D for ; Fri, 20 Apr 2012 21:55:29 +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=1335527729; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=aW6zpip8plS7SEhvO8sl 5Olo+1o=; b=B4rzdtP84L6nUi2NXX2+PwSBj88hNxL34a5Mt+uT9knKpzB1cbqm v1njbsBniFjPmSdqV4Fyqj8gs/xnWmU3rXruj+wpTeSr/u0VQkby/9pjl1DT+zz4 catebmSdb/n4ZSLejjq7UrbF5ojHD0FZZOcl6KtRzMJuITjGapuypqQ= 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:Subject:Message-ID:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Wg3IXMoZ4QNzEIV7y64MQW6GPDFKi+mP6Dj9DNkU04K5+99aWFwWc5ghwdNGmp tIFiVWcC+UyhLVCD1QBAbLpzjUe5+piNc4ppXr3QHzIxQmNRVvE7DNEVzcHfzKkk aCMwQqdtmOYZhUfNCb3lqToiqn3u2/sA6vJ4ngF8Po/co=; Received: (qmail 27695 invoked by alias); 20 Apr 2012 11:55:23 -0000 Received: (qmail 27684 invoked by uid 22791); 20 Apr 2012 11:55:22 -0000 X-SWARE-Spam-Status: No, hits=-5.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, TW_TM, T_RP_MATCHES_RCVD 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; Fri, 20 Apr 2012 11:55:09 +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 D6CB590182 for ; Fri, 20 Apr 2012 13:55:08 +0200 (CEST) Date: Fri, 20 Apr 2012 13:55:08 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix propagate_tree_value_into_stmt Message-ID: MIME-Version: 1.0 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 Which should properly care for updating VOPs. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2012-04-20 Richard Guenther * tree-ssa-copy.c (propagate_tree_value_into_stmt): Use update_call_from_tree when propagating into a call. * g++.dg/torture/20120420-1.C: New testcase. Index: gcc/tree-ssa-copy.c =================================================================== --- gcc/tree-ssa-copy.c (revision 186619) +++ gcc/tree-ssa-copy.c (working copy) @@ -257,13 +257,11 @@ propagate_tree_value_into_stmt (gimple_s else if (is_gimple_call (stmt) && gimple_call_lhs (stmt) != NULL_TREE) { - gimple new_stmt; - tree expr = NULL_TREE; + bool res; propagate_tree_value (&expr, val); - new_stmt = gimple_build_assign (gimple_call_lhs (stmt), expr); - move_ssa_defining_stmt_for_defs (new_stmt, stmt); - gsi_replace (gsi, new_stmt, false); + res = update_call_from_tree (gsi, expr); + gcc_assert (res); } else if (gimple_code (stmt) == GIMPLE_SWITCH) propagate_tree_value (gimple_switch_index_ptr (stmt), val); Index: gcc/testsuite/g++.dg/torture/20120420-1.C =================================================================== --- gcc/testsuite/g++.dg/torture/20120420-1.C (revision 0) +++ gcc/testsuite/g++.dg/torture/20120420-1.C (revision 0) @@ -0,0 +1,29 @@ +// { dg-do compile } + +int g, *gp[100]; +struct V { + int* x; + int y; +}; + +void foo (V **p, V* end, int i) +{ + *p = 0; + V* pp = *p; + int s = 100; + for (; pp < end; ) + { + pp++; + (pp-1)->x = &g; + if (g) + { + if (g>10) + g++; + int *t = (int*) operator new (100); + (pp-1)->x = t; + } + else + s--; + gp[end-pp] = (pp-1)->x + s; + } +}