From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25115 invoked by alias); 15 Feb 2013 17:54:13 -0000 Received: (qmail 25102 invoked by uid 22791); 15 Feb 2013 17:54:12 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,TW_TM X-Spam-Check-By: sourceware.org Received: from e8.ny.us.ibm.com (HELO e8.ny.us.ibm.com) (32.97.182.138) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 15 Feb 2013 17:54:07 +0000 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Feb 2013 12:54:06 -0500 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e8.ny.us.ibm.com (192.168.1.108) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 15 Feb 2013 12:53:49 -0500 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id B7D7838C8022 for ; Fri, 15 Feb 2013 12:53:48 -0500 (EST) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1FHrmBs345252 for ; Fri, 15 Feb 2013 12:53:48 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1FHrl6o010249 for ; Fri, 15 Feb 2013 12:53:48 -0500 Received: from [9.65.144.39] (sig-9-65-144-39.mts.ibm.com [9.65.144.39]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1FHrkGm010081; Fri, 15 Feb 2013 12:53:47 -0500 Message-ID: <1360950831.3498.59.camel@gnopaine> Subject: [PATCH] Fix PR56321 From: Bill Schmidt To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, bergner@vnet.ibm.com Date: Fri, 15 Feb 2013 17:54:00 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13021517-9360-0000-0000-000010A46A08 X-IsSubscribed: yes 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 X-SW-Source: 2013-02/txt/msg00783.txt.bz2 When we remove __builtin_pow statements as part of reassociation, we have to unlink the associated VDEF. We've always done this when we directly remove the statement. However, in reassociation the statements are sometimes modified in place instead of removed, potentially leaving one or more dangling VUSEs. This patch solves the problem by unlinking the VDEF when the statement's operands are added to the ops list. Bootstrapped and regression tested on powerpc64-unknown-linux-gnu with no new regressions. The new test case is the code that exposed the problem in PR56321. Ok for trunk? Thanks, Bill Index: gcc/testsuite/gcc.dg/tree-ssa/pr56321.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/pr56321.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-ssa/pr56321.c (revision 0) @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -ffast-math -fdump-tree-optimized" } */ + +float foo(int n) +{ + return ((2.0*n*n)/3.0+2.0*n); +} + +/* { dg-final { scan-tree-dump-times "__builtin_pow" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\* " 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\+ " 1 "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ Index: gcc/tree-ssa-reassoc.c =================================================================== --- gcc/tree-ssa-reassoc.c (revision 196053) +++ gcc/tree-ssa-reassoc.c (working copy) @@ -3386,6 +3386,10 @@ linearize_expr_tree (vec *ops, gi { add_repeat_to_ops_vec (ops, base, exponent); gimple_set_visited (binrhsdef, true); + // We may not physically remove the call later because + // stmts are preferably modified in place. But we have + // to remove any VDEF associated with the call regardless. + unlink_stmt_vdef (binrhsdef); } else add_to_ops_vec (ops, binrhs); @@ -3396,6 +3400,10 @@ linearize_expr_tree (vec *ops, gi { add_repeat_to_ops_vec (ops, base, exponent); gimple_set_visited (binlhsdef, true); + // We may not physically remove the call later because + // stmts are preferably modified in place. But we have + // to remove any VDEF associated with the call regardless. + unlink_stmt_vdef (binlhsdef); } else add_to_ops_vec (ops, binlhs); @@ -3445,6 +3453,10 @@ linearize_expr_tree (vec *ops, gi { add_repeat_to_ops_vec (ops, base, exponent); gimple_set_visited (SSA_NAME_DEF_STMT (binrhs), true); + // We may not physically remove the call later because + // stmts are preferably modified in place. But we have + // to remove any VDEF associated with the call regardless. + unlink_stmt_vdef (SSA_NAME_DEF_STMT (binrhs)); } else add_to_ops_vec (ops, binrhs);