From patchwork Wed Jul 18 13:59:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 171681 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 49E542C036E for ; Thu, 19 Jul 2012 00:00:45 +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=1343224846; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:Subject:From:To:Cc: In-Reply-To:References:Content-Type:Date:Message-ID:Mime-Version: Content-Transfer-Encoding:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=jgSnwm5+Oss49stOqLAd6fU4u/U=; b=Nk4OEw8+SEmjfNz c1gG+xUvKxtNEHqg7eDz6oUD4MQmADYU60iPohV4oq5+3bNUuZ5wirK5Aj7Tb994 ddtsWEKEIKnEEPunzEzpBtCcG/kpN01RSBMpzzt1MLFZW7UMyt0FQGAtAAeIBoNb dB/poHjC9W8hQfQ9xNk8mG9oJUvQ= 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:Received:Received:Received:Received:Received:Subject:From:To:Cc:In-Reply-To:References:Content-Type:Date:Message-ID:Mime-Version:Content-Transfer-Encoding:X-Content-Scanned:x-cbid:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=iA6Dstzr2e9ew+oQLbH+UsWWEW8bd/dP3ZVD5xyJRYVe9KDCAdX1nc0G3SCSqE dfG63vgaLmuiJMYHAYZ/sxhY6i+p1AGYrrq5BVChWIZpAMKOzphksW/Yv1uDIAYf tq/4SVhvrmft1wLWBZ5NvLnQsA93rGWYJBF7tctygBKNs=; Received: (qmail 23543 invoked by alias); 18 Jul 2012 14:00:36 -0000 Received: (qmail 23333 invoked by uid 22791); 18 Jul 2012 14:00:28 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL, BAYES_20, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, TW_IV, T_RP_MATCHES_RCVD 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; Wed, 18 Jul 2012 14:00:13 +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 ; Wed, 18 Jul 2012 10:00:11 -0400 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e8.ny.us.ibm.com (192.168.1.108) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 18 Jul 2012 09:59:47 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id C2B3B38C8068 for ; Wed, 18 Jul 2012 09:59:45 -0400 (EDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6IDxXoU30146744 for ; Wed, 18 Jul 2012 09:59:33 -0400 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6IDxR0s022701 for ; Wed, 18 Jul 2012 07:59:27 -0600 Received: from [9.10.86.212] (9-10-86-212.rchland.ibm.com [9.10.86.212]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6IDxRRK022651; Wed, 18 Jul 2012 07:59:27 -0600 Subject: Re: [PATCH] Add flag to control straight-line strength reduction From: "William J. Schmidt" To: Richard Guenther Cc: Steven Bosscher , gcc-patches@gcc.gnu.org, bergner@vnet.ibm.com In-Reply-To: References: <1342538095.3470.59.camel@gnopaine> Date: Wed, 18 Jul 2012 08:59:26 -0500 Message-ID: <1342619966.4590.11.camel@oc2474580526.ibm.com> Mime-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12071813-9360-0000-0000-00000883C462 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 Here's the patch with documentation changes included. I also cleaned up missing work from a couple of my previous patches, so -fhoist-adjacent-loads is documented now, and -fvect-cost-model is added to the list of options on by default at -O3. Ok for trunk? Thanks, Bill 2012-07-18 Bill Schmidt * doc/invoke.texi: Add -fhoist-adjacent-loads and -ftree-slsr to list of flags controlling optimization; add -ftree-slsr to list of flags enabled by default at -O; add -fhoist-adjacent-loads to list of flags enabled by default at -O2; add -fvect-cost-model to list of flags enabled by default at -O3; document -fhoist-adjacent-loads and -ftree-slsr. * opts.c (default_option): Make -ftree-slsr default at -O1 and above. * gimple-ssa-strength-reduction.c (gate_strength_reduction): Use flag_tree_slsr. * common.opt: Add -ftree-slsr with flag_tree_slsr. Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi (revision 189574) +++ gcc/doc/invoke.texi (working copy) @@ -364,7 +364,8 @@ Objective-C and Objective-C++ Dialects}. -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol -fforward-propagate -ffp-contract=@var{style} -ffunction-sections @gol -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity @gol --fgcse-sm -fif-conversion -fif-conversion2 -findirect-inlining @gol +-fgcse-sm -fhoist-adjacent-loads -fif-conversion @gol +-fif-conversion2 -findirect-inlining @gol -finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol -finline-small-functions -fipa-cp -fipa-cp-clone -fipa-matrix-reorg @gol -fipa-pta -fipa-profile -fipa-pure-const -fipa-reference @gol @@ -413,8 +414,8 @@ Objective-C and Objective-C++ Dialects}. -ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns @gol -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta @gol --ftree-reassoc @gol --ftree-sink -ftree-sra -ftree-switch-conversion -ftree-tail-merge @gol +-ftree-reassoc -ftree-sink -ftree-slsr -ftree-sra @gol +-ftree-switch-conversion -ftree-tail-merge @gol -ftree-ter -ftree-vect-loop-version -ftree-vectorize -ftree-vrp @gol -funit-at-a-time -funroll-all-loops -funroll-loops @gol -funsafe-loop-optimizations -funsafe-math-optimizations -funswitch-loops @gol @@ -6259,6 +6260,7 @@ compilation time. -ftree-forwprop @gol -ftree-fre @gol -ftree-phiprop @gol +-ftree-slsr @gol -ftree-sra @gol -ftree-pta @gol -ftree-ter @gol @@ -6286,6 +6288,7 @@ also turns on the following optimization flags: -fdevirtualize @gol -fexpensive-optimizations @gol -fgcse -fgcse-lm @gol +-fhoist-adjacent-loads @gol -finline-small-functions @gol -findirect-inlining @gol -fipa-sra @gol @@ -6311,6 +6314,7 @@ Optimize yet more. @option{-O3} turns on all opti by @option{-O2} and also turns on the @option{-finline-functions}, @option{-funswitch-loops}, @option{-fpredictive-commoning}, @option{-fgcse-after-reload}, @option{-ftree-vectorize}, +@option{-fvect-cost-model}, @option{-ftree-partial-pre} and @option{-fipa-cp-clone} options. @item -O0 @@ -7129,6 +7133,13 @@ This flag is enabled by default at @option{-O} and Perform hoisting of loads from conditional pointers on trees. This pass is enabled by default at @option{-O} and higher. +@item -fhoist-adjacent-loads +@opindex hoist-adjacent-loads +Speculatively hoist loads from both branches of an if-then-else if the +loads are from adjacent locations in the same structure and the target +architecture has a conditional move instruction. This flag is enabled +by default at @option{-O2} and higher. + @item -ftree-copy-prop @opindex ftree-copy-prop Perform copy propagation on trees. This pass eliminates unnecessary @@ -7529,6 +7540,13 @@ defining expression. This results in non-GIMPLE c much more complex trees to work on resulting in better RTL generation. This is enabled by default at @option{-O} and higher. +@item -ftree-slsr +@opindex ftree-slsr +Perform straight-line strength reduction on trees. This recognizes related +expressions involving multiplications and replaces them by less expensive +calculations when possible. This is enabled by default at @option{-O} and +higher. + @item -ftree-vectorize @opindex ftree-vectorize Perform loop vectorization on trees. This flag is enabled by default at @@ -7550,7 +7568,8 @@ except at level @option{-Os} where it is disabled. @item -fvect-cost-model @opindex fvect-cost-model -Enable cost model for vectorization. +Enable cost model for vectorization. This option is enabled by default at +@option{-O3}. @item -ftree-vrp @opindex ftree-vrp Index: gcc/opts.c =================================================================== --- gcc/opts.c (revision 189574) +++ gcc/opts.c (working copy) @@ -452,6 +452,7 @@ static const struct default_options default_option { OPT_LEVELS_1_PLUS, OPT_ftree_ch, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fcombine_stack_adjustments, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fcompare_elim, NULL, 1 }, + { OPT_LEVELS_1_PLUS, OPT_ftree_slsr, NULL, 1 }, /* -O2 optimizations. */ { OPT_LEVELS_2_PLUS, OPT_finline_small_functions, NULL, 1 }, Index: gcc/gimple-ssa-strength-reduction.c =================================================================== --- gcc/gimple-ssa-strength-reduction.c (revision 189574) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -1501,7 +1501,7 @@ execute_strength_reduction (void) static bool gate_strength_reduction (void) { - return optimize > 0; + return flag_tree_slsr; } struct gimple_opt_pass pass_strength_reduction = Index: gcc/common.opt =================================================================== --- gcc/common.opt (revision 189574) +++ gcc/common.opt (working copy) @@ -2080,6 +2080,10 @@ ftree-sink Common Report Var(flag_tree_sink) Optimization Enable SSA code sinking on trees +ftree-slsr +Common Report Var(flag_tree_slsr) Optimization +Perform straight-line strength reduction + ftree-sra Common Report Var(flag_tree_sra) Optimization Perform scalar replacement of aggregates