From patchwork Thu Dec 17 23:34:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 558687 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7B27E1402F0 for ; Fri, 18 Dec 2015 10:34:11 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=JSyISYrF; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=EDZURE6bMOCR2luQvbeJ5tBs0PZMxSGb2eO2ageQWFB/VaCwgf +hWnkeKeW5YYxyRUIFPMNNHxZChMPcIm1An3Qp3RuH8MNTwsadrsQaAmaNDUvAjS XeC38Ei+tZLSuaFi+da849BNo31HqRBB9Hz9OveB8LE2OPqbO0QPRhMXk= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=A2ixSZNQf5HjEKNKr1ae8XyxUpg=; b=JSyISYrF8qUk65y3cIF/ JN4aRB4tZcXvNliX6o/107InuQmmfCH9Zc4ppXdUhOlJiy0nILYssPDV6FVFwMva IJHxtld6jKOmYccj9EYYy7wX2BqPG/zYC/oiwhwa+P4so5G4KcmLCY0u1JetJLt8 Pey7B6JeSyBNVBwKMrvt8aM= Received: (qmail 16046 invoked by alias); 17 Dec 2015 23:34:03 -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 16032 invoked by uid 89); 17 Dec 2015 23:34:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=297, 7852, 7, 78527, UD:ipa-icf.c X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 17 Dec 2015 23:34:02 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id DA69C8A14F for ; Thu, 17 Dec 2015 23:34:00 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-83.phx2.redhat.com [10.3.113.83]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBHNY09k029638 for ; Thu, 17 Dec 2015 18:34:00 -0500 To: gcc-patches@gcc.gnu.org From: Jeff Law Subject: [PATCH] Limit path splitting to loops we optimize for speed Message-ID: <56734668.9060301@redhat.com> Date: Thu, 17 Dec 2015 16:34:00 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 X-IsSubscribed: yes It's not currently clear what the final disposition for the path splitting code will be. However, there's no reason not to implement Richi's request that we only do this transformation when optimizing for speed and at optimization levels higher than -O2. This patch limits the transformation to loops where optimize_loop_for_speed_p is true. The patch also moves the transformation to -O3. Bootstrapped & regression tested on x86_64-linux-gnu. Installed on the trunk. Jeff commit 47545a4249a6d9ff3003e0e98a11aced97c6c7e1 Author: Jeff Law Date: Thu Dec 17 16:32:19 2015 -0700 [PATCH] Limit path splitting to loops we optimize for speed * doc/invoke.texi (-O2 options): Remove -fsplit-paths. (-O3 options): Add -fsplit-paths. * gimple-ssa-split-paths.c: Include predict.h (split_paths): Only split paths in a loop that should be optimized for speed. * opts.c (default_options_table): Move -fsplit-paths from -O2 to -O3. * gcc.dg/tree-ssa/split-path-1.c: Explicitly ask for path splitting optimizations. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a1f71bd..070b2dd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-12-17 Jeff Law + + * doc/invoke.texi (-O2 options): Remove -fsplit-paths. + (-O3 options): Add -fsplit-paths. + * gimple-ssa-split-paths.c: Include predict.h + (split_paths): Only split paths in a loop that should be + optimized for speed. + * opts.c (default_options_table): Move -fsplit-paths from -O2 to + -O3. + 2015-12-17 Nathan Sidwell * ipa-icf.c (sem_item_optimizer::merge): Don't pick 'main' as the diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index cdc5d2c..60530c0 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -7836,7 +7836,6 @@ also turns on the following optimization flags: -frerun-cse-after-loop @gol -fsched-interblock -fsched-spec @gol -fschedule-insns -fschedule-insns2 @gol --fsplit-paths @gol -fstrict-aliasing -fstrict-overflow @gol -ftree-builtin-call-dce @gol -ftree-switch-conversion -ftree-tail-merge @gol @@ -7853,7 +7852,7 @@ Optimize yet more. @option{-O3} turns on all optimizations specified by @option{-O2} and also turns on the @option{-finline-functions}, @option{-funswitch-loops}, @option{-fpredictive-commoning}, @option{-fgcse-after-reload}, @option{-ftree-loop-vectorize}, -@option{-ftree-loop-distribute-patterns}, +@option{-ftree-loop-distribute-patterns}, @option{-fsplit-paths} @option{-ftree-slp-vectorize}, @option{-fvect-cost-model}, @option{-ftree-partial-pre} and @option{-fipa-cp-clone} options. diff --git a/gcc/gimple-ssa-split-paths.c b/gcc/gimple-ssa-split-paths.c index 602e916..540fdf3 100644 --- a/gcc/gimple-ssa-split-paths.c +++ b/gcc/gimple-ssa-split-paths.c @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "gimple-iterator.h" #include "tracer.h" +#include "predict.h" /* Given LATCH, the latch block in a loop, see if the shape of the path reaching LATCH is suitable for being split by duplication. @@ -180,9 +181,14 @@ split_paths () FOR_EACH_LOOP (loop, LI_FROM_INNERMOST) { + /* Only split paths if we are optimizing this loop for speed. */ + if (!optimize_loop_for_speed_p (loop)) + continue; + /* See if there is a block that we can duplicate to split the path to the loop latch. */ - basic_block bb = find_block_to_duplicate_for_splitting_paths (loop->latch); + basic_block bb + = find_block_to_duplicate_for_splitting_paths (loop->latch); /* BB is the merge point for an IF-THEN-ELSE we want to transform. diff --git a/gcc/opts.c b/gcc/opts.c index d46f304..7ab585f 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -523,11 +523,11 @@ static const struct default_options default_options_table[] = { OPT_LEVELS_2_PLUS, OPT_fisolate_erroneous_paths_dereference, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_fipa_ra, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_flra_remat, NULL, 1 }, - { OPT_LEVELS_2_PLUS, OPT_fsplit_paths, NULL, 1 }, /* -O3 optimizations. */ { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 }, { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 }, + { OPT_LEVELS_3_PLUS, OPT_fsplit_paths, NULL, 1 }, /* Inlining of functions reducing size is a good idea with -Os regardless of them being declared inline. */ { OPT_LEVELS_3_PLUS_AND_SIZE, OPT_finline_functions, NULL, 1 }, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d5ae299..baa159d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-17 Jeff Law + + * gcc.dg/tree-ssa/split-path-1.c: Explicitly ask for path + splitting optimizations. + 2015-12-17 Nathan Sidwell * gcc.dg/ipa/ipa-icf-merge-1.c: New. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c b/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c index 5c96241..b24f6a9 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O2 -fdump-tree-split-paths-details " } */ +/* { dg-options "-O2 -fsplit-paths -fdump-tree-split-paths-details " } */ #include #include