From patchwork Tue Jan 24 21:26:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 137657 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 1EA06B6F71 for ; Wed, 25 Jan 2012 08:30:11 +1100 (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=1328045412; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:User-Agent:Cc:MIME-Version: Content-Type:Message-Id:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=K/SaBjC+hJesDp4qFBsbeoo4Mw4=; b=wlPNt3A/LN3w2GN qF/oW2DZb6hYujWp65L9fg+fu0pqdHr6BMCRH/ktJ7kvZamKIcyfknlWAgdop8tq MRLU4AiV6S9fEl6TnLpogfgUAc7htV0a+s9Wn2OgpOxkAzzqGFxPEKg0JQJZ11Gx 7KbdC6F09wy9uFceIt9YnAsAb298= 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:From:To:Subject:Date:User-Agent:Cc:MIME-Version:Content-Type:Message-Id:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=qx0gZbrskEJXQub03zguTVJf/69EbZ8ZqHqAwZDDtFL5PPZihDd2JTKdS31uo7 HSzZgL/e4QAAwcjbvrXP+zc70DSckfM05b3fJM5R7OO1xR68+8oQEOoTBbrhTG5G fv34XQa5IJEEwx5FJs/B4oavoZipEQqmnf1l+wsNBLnzg=; Received: (qmail 25062 invoked by alias); 24 Jan 2012 21:30:06 -0000 Received: (qmail 25000 invoked by uid 22791); 24 Jan 2012 21:30:02 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, TW_CF, TW_FW X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Jan 2012 21:29:49 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 530EECB3F29; Tue, 24 Jan 2012 22:29:49 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oi5FcObbaj7Z; Tue, 24 Jan 2012 22:29:49 +0100 (CET) Received: from [192.168.1.2] (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 1663ECB3B39; Tue, 24 Jan 2012 22:29:49 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [RFC] Disable FWPROP on pathological cases Date: Tue, 24 Jan 2012 22:26:28 +0100 User-Agent: KMail/1.9.9 Cc: Paolo Bonzini MIME-Version: 1.0 Message-Id: <201201242226.29027.ebotcazou@adacore.com> 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 Starting with the 4.5.x series, we have pathological cases (Ada code generated by a code generator from a model) where FWPROP takes 80% of the compilation time at -O1 (for essentially no benefits). There are very few basic blocks (typically 1) and tens of thousands of uses registered with DF, so processing them takes a while (top function in the profile: local_ref_killed_between_p). The attached patch is an attempt (modelled on gcse.c) at disabling the pass for these pathological cases. Thoughts? * Makefile.in (fwprop.o): Add intl.h. * fwprop.c: Include intl.h. (is_too_expensive): New function. (fwprop): Call it and return early if it returns true. (fwprop_addr): Likewise. Index: Makefile.in =================================================================== --- Makefile.in (revision 183423) +++ Makefile.in (working copy) @@ -3023,9 +3023,10 @@ dse.o : dse.c $(CONFIG_H) $(SYSTEM_H) co $(TREE_PASS_H) alloc-pool.h $(ALIAS_H) dse.h $(OPTABS_H) $(TARGET_H) \ $(BITMAP_H) $(PARAMS_H) fwprop.o : fwprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ - $(DIAGNOSTIC_CORE_H) insn-config.h $(RECOG_H) $(FLAGS_H) $(OBSTACK_H) $(BASIC_BLOCK_H) \ - output.h $(DF_H) alloc-pool.h $(TIMEVAR_H) $(TREE_PASS_H) $(TARGET_H) \ - $(TM_P_H) $(CFGLOOP_H) $(EMIT_RTL_H) domwalk.h sparseset.h + $(DIAGNOSTIC_CORE_H) insn-config.h $(RECOG_H) $(FLAGS_H) $(OBSTACK_H) \ + intl.h $(BASIC_BLOCK_H) output.h $(DF_H) alloc-pool.h $(TIMEVAR_H) \ + $(TREE_PASS_H) $(TARGET_H) $(TM_P_H) $(CFGLOOP_H) $(EMIT_RTL_H) \ + domwalk.h sparseset.h web.o : web.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ hard-reg-set.h $(FLAGS_H) $(BASIC_BLOCK_H) $(FUNCTION_H) output.h $(DIAGNOSTIC_CORE_H) \ insn-config.h $(RECOG_H) $(DF_H) $(OBSTACK_H) $(TIMEVAR_H) $(TREE_PASS_H) Index: fwprop.c =================================================================== --- fwprop.c (revision 183423) +++ fwprop.c (working copy) @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. #include "insn-config.h" #include "recog.h" #include "flags.h" +#include "intl.h" #include "obstack.h" #include "basic-block.h" #include "output.h" @@ -1435,6 +1436,28 @@ fwprop_done (void) } +/* Return true if the function is too expensive to optimize. PASS is the + optimization about to be performed. */ + +static bool +is_too_expensive (const char *pass) +{ + int ratio = DF_USES_TABLE_SIZE () / (n_basic_blocks - NUM_FIXED_BLOCKS); + + /* Trying to propagate into uses in functions with gigantic basic blocks + will take a long time and is unlikely to be particularly useful. */ + if (ratio > 20000) + { + warning (OPT_Wdisabled_optimization, + "%s: %d basic blocks and %d uses/basic block", + pass, n_basic_blocks - NUM_FIXED_BLOCKS, ratio); + + return true; + } + + return false; +} + /* Main entry point. */ static bool @@ -1451,6 +1474,12 @@ fwprop (void) fwprop_init (); + if (is_too_expensive (_("FWPROP1 disabled"))) + { + fwprop_done (); + return 0; + } + /* Go through all the uses. df_uses_create will create new ones at the end, and we'll go through them as well. @@ -1469,8 +1498,10 @@ fwprop (void) } fwprop_done (); + if (need_cleanup) cleanup_cfg (0); + return 0; } @@ -1503,6 +1534,12 @@ fwprop_addr (void) fwprop_init (); + if (is_too_expensive (_("FWPROP2 disabled"))) + { + fwprop_done (); + return 0; + } + /* Go through all the uses. df_uses_create will create new ones at the end, and we'll go through them as well. */ for (i = 0; i < DF_USES_TABLE_SIZE (); i++) @@ -1520,6 +1557,7 @@ fwprop_addr (void) if (need_cleanup) cleanup_cfg (0); + return 0; }