From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23260 invoked by alias); 3 Dec 2015 10:46:53 -0000 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 Received: (qmail 23232 invoked by uid 89); 3 Dec 2015 10:46:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 03 Dec 2015 10:46:51 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E6C9FAAC1; Thu, 3 Dec 2015 10:46:48 +0000 (UTC) Date: Thu, 03 Dec 2015 10:46:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jan Hubicka Subject: [PATCH] Handle OBJ_TYPE_REF in FRE Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2015-12/txt/msg00415.txt.bz2 The following patch handles CSEing OBJ_TYPE_REF which was omitted because it is a GENERIC expression even on GIMPLE (for whatever reason...). Rather than changing this now the following patch simply treats it properly as such. Bootstrap & regtest running on x86_64-unknown-linux-gnu. Note that this does not (yet) substitute OBJ_TYPE_REFs in calls with SSA names that have the same value - not sure if that would be desired generally (does the devirt machinery cope with that?). Thanks, Richard. 2015-12-03 Richard Biener PR tree-optimization/64812 * tree-ssa-sccvn.c (vn_get_stmt_kind): Handle OBJ_TYPE_REF. (vn_nary_length_from_stmt): Likewise. (init_vn_nary_op_from_stmt): Likewise. * gimple-match-head.c (maybe_build_generic_op): Likewise. * gimple-pretty-print.c (dump_unary_rhs): Likewise. * g++.dg/tree-ssa/ssa-fre-1.C: New testcase. Index: gcc/tree-ssa-sccvn.c =================================================================== *** gcc/tree-ssa-sccvn.c (revision 231221) --- gcc/tree-ssa-sccvn.c (working copy) *************** vn_get_stmt_kind (gimple *stmt) *** 460,465 **** --- 460,467 ---- ? VN_CONSTANT : VN_REFERENCE); else if (code == CONSTRUCTOR) return VN_NARY; + else if (code == OBJ_TYPE_REF) + return VN_NARY; return VN_NONE; } default: *************** vn_nary_length_from_stmt (gimple *stmt) *** 2479,2484 **** --- 2481,2487 ---- return 1; case BIT_FIELD_REF: + case OBJ_TYPE_REF: return 3; case CONSTRUCTOR: *************** init_vn_nary_op_from_stmt (vn_nary_op_t *** 2508,2513 **** --- 2511,2517 ---- break; case BIT_FIELD_REF: + case OBJ_TYPE_REF: vno->length = 3; vno->op[0] = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0); vno->op[1] = TREE_OPERAND (gimple_assign_rhs1 (stmt), 1); Index: gcc/gimple-match-head.c =================================================================== *** gcc/gimple-match-head.c (revision 231221) --- gcc/gimple-match-head.c (working copy) *************** maybe_build_generic_op (enum tree_code c *** 243,248 **** --- 243,249 ---- *op0 = build1 (code, type, *op0); break; case BIT_FIELD_REF: + case OBJ_TYPE_REF: *op0 = build3 (code, type, *op0, op1, op2); break; default:; Index: gcc/gimple-pretty-print.c =================================================================== *** gcc/gimple-pretty-print.c (revision 231221) --- gcc/gimple-pretty-print.c (working copy) *************** dump_unary_rhs (pretty_printer *buffer, *** 302,308 **** || TREE_CODE_CLASS (rhs_code) == tcc_reference || rhs_code == SSA_NAME || rhs_code == ADDR_EXPR ! || rhs_code == CONSTRUCTOR) { dump_generic_node (buffer, rhs, spc, flags, false); break; --- 302,309 ---- || TREE_CODE_CLASS (rhs_code) == tcc_reference || rhs_code == SSA_NAME || rhs_code == ADDR_EXPR ! || rhs_code == CONSTRUCTOR ! || rhs_code == OBJ_TYPE_REF) { dump_generic_node (buffer, rhs, spc, flags, false); break; Index: gcc/testsuite/g++.dg/tree-ssa/ssa-fre-1.C =================================================================== *** gcc/testsuite/g++.dg/tree-ssa/ssa-fre-1.C (revision 0) --- gcc/testsuite/g++.dg/tree-ssa/ssa-fre-1.C (working copy) *************** *** 0 **** --- 1,44 ---- + /* { dg-do compile } */ + /* { dg-options "-O2 -fdump-tree-fre2" } */ + + template class A + { + T *p; + + public: + A (T *p1) : p (p1) { p->acquire (); } + }; + + class B + { + public: + virtual void acquire (); + }; + class D : public B + { + }; + class F : B + { + int mrContext; + }; + class WindowListenerMultiplexer : F, public D + { + void acquire () { acquire (); } + }; + class C + { + void createPeer () throw (); + WindowListenerMultiplexer maWindowListeners; + }; + class FmXGridPeer + { + public: + void addWindowListener (A); + } a; + void + C::createPeer () throw () + { + a.addWindowListener (&maWindowListeners); + } + + /* { dg-final { scan-tree-dump-times "= OBJ_TYPE_REF" 1 "fre2" } } */