From patchwork Wed Jul 7 22:52:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 58203 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 D376FB6F15 for ; Thu, 8 Jul 2010 08:53:13 +1000 (EST) Received: (qmail 15936 invoked by alias); 7 Jul 2010 22:53:12 -0000 Received: (qmail 15926 invoked by uid 22791); 7 Jul 2010 22:53:11 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_IV, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-pv0-f175.google.com (HELO mail-pv0-f175.google.com) (74.125.83.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Jul 2010 22:53:06 +0000 Received: by pvg13 with SMTP id 13so79449pvg.20 for ; Wed, 07 Jul 2010 15:53:05 -0700 (PDT) Received: by 10.114.113.5 with SMTP id l5mr8454825wac.155.1278543184893; Wed, 07 Jul 2010 15:53:04 -0700 (PDT) Received: from napoca ([163.181.251.115]) by mx.google.com with ESMTPS id s5sm107225892wak.12.2010.07.07.15.53.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 07 Jul 2010 15:53:04 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Wed, 07 Jul 2010 17:53:00 -0500 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, Sebastian Pop Subject: [PATCH 1/4] Add the -ftree-loop-if-convert flag. Date: Wed, 7 Jul 2010 17:52:48 -0500 Message-Id: <1278543168-11395-1-git-send-email-sebpop@gmail.com> In-Reply-To: References: X-IsSubscribed: yes 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 * common.opt (ftree-loop-if-convert): New flag. * doc/invoke.texi (ftree-loop-if-convert): Documented. * tree-if-conv.c (gate_tree_if_conversion): Enable if-conversion when flag_tree_loop_if_convert is set. --- gcc/common.opt | 4 ++++ gcc/doc/invoke.texi | 14 ++++++++++---- gcc/tree-if-conv.c | 6 +++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 6ca787a..111d7b7 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -653,6 +653,10 @@ fif-conversion2 Common Report Var(flag_if_conversion2) Optimization Perform conversion of conditional jumps to conditional execution +ftree-loop-if-convert +Common Report Var(flag_tree_loop_if_convert) Init(-1) Optimization +Convert conditional jumps in innermost loops to branchless equivalents + ; -finhibit-size-directive inhibits output of .size for ELF. ; This is used only for compiling crtstuff.c, ; and it may be extended to other effects diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d70f130..0847e01 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -342,7 +342,7 @@ Objective-C and Objective-C++ Dialects}. -fearly-inlining -fipa-sra -fexpensive-optimizations -ffast-math @gol -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol -fforward-propagate -ffunction-sections @gol --fgcse -fgcse-after-reload -fgcse-las -fgcse-lm @gol +-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity @gol -fgcse-sm -fif-conversion -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 -fipa-pta @gol @@ -352,7 +352,7 @@ Objective-C and Objective-C++ Dialects}. -fira-loop-pressure -fno-ira-share-save-slots @gol -fno-ira-share-spill-slots -fira-verbose=@var{n} @gol -fivopts -fkeep-inline-functions -fkeep-static-consts @gol --floop-block -floop-interchange -floop-strip-mine -fgraphite-identity @gol +-floop-block -floop-interchange -floop-strip-mine @gol -floop-parallelize-all -flto -flto-compression-level -flto-report -fltrans @gol -fltrans-output-list -fmerge-all-constants -fmerge-constants -fmodulo-sched @gol -fmodulo-sched-allow-regmoves -fmove-loop-invariants -fmudflap @gol @@ -382,8 +382,8 @@ Objective-C and Objective-C++ Dialects}. -fsplit-wide-types -fstack-protector -fstack-protector-all @gol -fstrict-aliasing -fstrict-overflow -fthread-jumps -ftracer @gol -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copy-prop @gol --ftree-copyrename -ftree-dce @gol --ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -ftree-loop-im @gol +-ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse @gol +-ftree-forwprop -ftree-fre -ftree-loop-if-convert -ftree-loop-im @gol -ftree-phiprop -ftree-loop-distribution @gol -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-pta -ftree-reassoc @gol @@ -6883,6 +6883,12 @@ profitable to parallelize the loops. Compare the results of several data dependence analyzers. This option is used for debugging the data dependence analyzers. +@item -ftree-loop-if-convert +Attempt to transform conditional jumps in the innermost loops to +branch-less equivalents. The intent is to remove control-flow from +the innermost loops in order to improve the ability of the +auto-vectorization pass to handle these loops. + @item -ftree-loop-distribution Perform loop distribution. This flag can improve cache performance on big loop bodies and allow further loop optimizations, like diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 8d5d226..873cd89 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -1242,7 +1242,11 @@ main_tree_if_conversion (void) static bool gate_tree_if_conversion (void) { - return flag_tree_vectorize != 0; + if (flag_tree_vectorize + && flag_tree_loop_if_convert < 0) + flag_tree_loop_if_convert = 1; + + return flag_tree_loop_if_convert > 0; } struct gimple_opt_pass pass_if_conversion =