From patchwork Sat Nov 9 15:47:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 289997 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4DB232C00C2 for ; Sun, 10 Nov 2013 02:47:58 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=m/3euYk/31fCiL6KbnCz16aFxR0TO3hXY5SfBtGYoOZ qGqlh/6inYneIjMvAERc5mknkH68GTR1Cf3FhysIX7ZfuBLZUXh6BpvGalP817mx 19B3O7WU3x0uQtKlqhI7NoYRTfeI+GSklCIyNvmtDK7u0Ws2KSW3YYit9nwlMEsk = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=SaHs6ftJjvZSsaHYFeeSv1vf4v8=; b=jxihGGlZRTqVo7dQT rsNTUIftWbjqsjUjR4fuNIaB30GXJ2wjzJPme58LoFz6hCufiAGqWuHKDXWZsGUs Fl6ony8jWlbf38RKC/5OLCBoeG+SiXqKrGt6IDFigazy7TgDRe658B/X3bRx3JGl AvDBiVj/LHGmHGxGPi+3R5K4Ec= Received: (qmail 32409 invoked by alias); 9 Nov 2013 15:47:45 -0000 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 Received: (qmail 32399 invoked by uid 89); 9 Nov 2013 15:47:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Nov 2013 15:47:43 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1VfAkw-0004Ii-Nm from Tom_deVries@mentor.com ; Sat, 09 Nov 2013 07:47:26 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sat, 9 Nov 2013 07:47:26 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Sat, 9 Nov 2013 15:47:24 +0000 Message-ID: <527E590A.9060608@mentor.com> Date: Sat, 9 Nov 2013 16:47:22 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Richard Biener CC: Subject: [PATCH] Factor out gimple_dont_merge_p Richard, This patch factors out gimple_dont_merge_p from gimple_equal_p and find_duplicate. Bootstrapped and regtested on x86_64. OK for trunk? Thanks, - Tom 2013-11-06 Tom de Vries * tree-ssa-tail-merge.c (gimple_dont_merge_p): Factor function out of ... (gimple_equal_p): ... here, and ... (find_duplicate): ... here. Use gimple_dont_merge_p. diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c index 00dd071..4223094 100644 --- a/gcc/tree-ssa-tail-merge.c +++ b/gcc/tree-ssa-tail-merge.c @@ -1075,6 +1075,38 @@ set_cluster (basic_block bb1, basic_block bb2) gcc_unreachable (); } +/* Return true if tail-merge should refrain from merging STMT with another + stmt. */ + +static bool +gimple_dont_merge_p (gimple stmt) +{ + switch (gimple_code (stmt)) + { + case GIMPLE_CALL: + /* Eventually, we'll significantly complicate the CFG by adding + back edges to properly model the effects of transaction restart. + For the bulk of optimization this does not matter, but what we + cannot recover from is tail merging blocks between two separate + transactions. Avoid that by making commit not match. */ + if (gimple_call_builtin_p (stmt, BUILT_IN_TM_COMMIT)) + return true; + + /* We cannot tail-merge the builtins that end transactions. + ??? The alternative being unsharing of BBs in the tm_init pass. */ + if (flag_tm + && (gimple_call_flags (stmt) & ECF_TM_BUILTIN) + && is_tm_ending_fndecl (gimple_call_fndecl (stmt))) + return true; + + break; + default: + break; + } + + return false; +} + /* Return true if gimple statements S1 and S2 are equal. Gimple_bb (s1) and gimple_bb (s2) are members of SAME_SUCC. */ @@ -1099,14 +1131,6 @@ gimple_equal_p (same_succ same_succ, gimple s1, gimple s2) if (!gimple_call_same_target_p (s1, s2)) return false; - /* Eventually, we'll significantly complicate the CFG by adding - back edges to properly model the effects of transaction restart. - For the bulk of optimization this does not matter, but what we - cannot recover from is tail merging blocks between two separate - transactions. Avoid that by making commit not match. */ - if (gimple_call_builtin_p (s1, BUILT_IN_TM_COMMIT)) - return false; - for (i = 0; i < gimple_call_num_args (s1); ++i) { t1 = gimple_call_arg (s1, i); @@ -1220,15 +1244,15 @@ find_duplicate (same_succ same_succ, basic_block bb1, basic_block bb2) gimple stmt1 = gsi_stmt (gsi1); gimple stmt2 = gsi_stmt (gsi2); - if (!gimple_equal_p (same_succ, stmt1, stmt2)) + /* This should be tested also on local statements, but given the current + content of gimple_dont_merge_p, that's not necessary atm. What could + be better is to blacklist the bb containing the stmt, when encountering + the stmt f.i. in same_succ_hash. */ + if (gimple_dont_merge_p (stmt1) + || gimple_dont_merge_p (stmt2)) return; - // We cannot tail-merge the builtins that end transactions. - // ??? The alternative being unsharing of BBs in the tm_init pass. - if (flag_tm - && is_gimple_call (stmt1) - && (gimple_call_flags (stmt1) & ECF_TM_BUILTIN) - && is_tm_ending_fndecl (gimple_call_fndecl (stmt1))) + if (!gimple_equal_p (same_succ, stmt1, stmt2)) return; gsi_prev_nondebug (&gsi1);