From patchwork Fri Sep 21 11:03:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 185690 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 905612C0089 for ; Fri, 21 Sep 2012 21:07:16 +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=1348830437; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=ZKv+QtxrCmJSoRPpmMqn ihx8klo=; b=tI+FB4q+hfHjmKHUHjWj2S+vBkAMay0QLgxDFW+HFRQlKLZhP+VU rZwPepv5jS1ahyEN1ev2Y2+Qt1dJUhpDXs0V6EOYqtrpCVfzwgKU7nLQf87d0d4S i9KA2XujJoMq4s5oYssdF5bMxLmGaylK5IoTaFPR62C57GN4vGymoqU= 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:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=m3TQ8jlHA0R/ZJW2M1N1YmxpBAjw9Z+u+oDmSgiVV4Etr4ExuWPaPSjSj6JGic GSMxFRjkibqftQpUy2xSdfk25aX0Q10mrR1s7L4msqilIhVIYJkYkCpUsrQlr9wf Hojh5vDr8AjNjfPQ3zKNHUYB48YhHp7r/lmky3XOzOl/c=; Received: (qmail 15203 invoked by alias); 21 Sep 2012 11:07:10 -0000 Received: (qmail 15194 invoked by uid 22791); 21 Sep 2012 11:07:09 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, TW_TM 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, 21 Sep 2012 11:06:54 +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 11A59A2C8B for ; Fri, 21 Sep 2012 13:06:53 +0200 (CEST) Date: Fri, 21 Sep 2012 13:03:49 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR54647 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) 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 The introduction of vn_get_stmt_kind brought COND_EXPR and VEC_COND_EXPR into the PRE machinery - both are not really suited for SCCVN or PRE in NARY form as they contain an embedded expression. The following patch restores previous behavior. Eventually we could experiment with moving them to REFERENCE instead. Bootstrap and regtest pending on x86_64-unknown-linux-gnu. Btw, this also means they are presenting a VN barrier and do not get simplified if the condition would simplify. Richard. 2012-09-21 Richard Guenther PR tree-optimization/54647 * tree-ssa-pre.c (compute_avail): Do not put COND_EXPR or VEC_COND_EXPR into EXP_GEN again. * g++.dg/torture/pr54647.C: New testcase. Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c (revision 191603) +++ gcc/tree-ssa-pre.c (working copy) @@ -3981,9 +3838,18 @@ compute_avail (void) { case VN_NARY: { + enum tree_code code = gimple_assign_rhs_code (stmt); vn_nary_op_t nary; + + /* COND_EXPR and VEC_COND_EXPR are awkward in + that they contain an embedded complex expression. + Don't even try to shove those through PRE. */ + if (code == COND_EXPR + || code == VEC_COND_EXPR) + continue; + vn_nary_op_lookup_pieces (gimple_num_ops (stmt) - 1, - gimple_assign_rhs_code (stmt), + code, gimple_expr_type (stmt), gimple_assign_rhs1_ptr (stmt), &nary); Index: gcc/testsuite/g++.dg/torture/pr54647.C =================================================================== --- gcc/testsuite/g++.dg/torture/pr54647.C (revision 0) +++ gcc/testsuite/g++.dg/torture/pr54647.C (working copy) @@ -0,0 +1,25 @@ +// { dg-do compile } + +class A +{ +}; +template struct D:A +{ + type & operator[](int); +}; +struct B +{ + typedef D Row; + struct C + { + Row *row; + }; +}; +B::C a; +B::Row & b = *a.row; +void +fn1 () +{ + while (1) + b[0] = b[0] ? (int *) -1 : 0; +}