From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4062 invoked by alias); 14 Oct 2004 18:36:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 4055 invoked from network); 14 Oct 2004 18:36:56 -0000 Received: from unknown (HELO smtp3.fuse.net) (216.68.8.176) by sourceware.org with SMTP; 14 Oct 2004 18:36:56 -0000 Received: from gx5.fuse.net ([66.42.131.190]) by smtp3.fuse.net (InterMail vM.6.01.03.04 201-2131-111-106-20040729) with ESMTP id <20041014183656.DEWQ22310.smtp3.fuse.net@gx5.fuse.net> for ; Thu, 14 Oct 2004 14:36:56 -0400 Received: from dellpi.pinski.fam ([66.42.131.190]) by gx5.fuse.net (InterMail vG.1.00.00.00 201-2136-104-20040331) with ESMTP id <20041014183655.HTCE10526.gx5.fuse.net@dellpi.pinski.fam>; Thu, 14 Oct 2004 14:36:55 -0400 Received: from [10.0.0.80] (zhivago.i.pinski.fam [10.0.0.80]) by dellpi.pinski.fam (8.12.2/8.12.1) with ESMTP id i9EIahVT010266; Thu, 14 Oct 2004 14:36:44 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v618) To: GCC Patches Message-Id: Content-Type: multipart/mixed; boundary=Apple-Mail-6--787282964 Cc: Jan Hubicka Subject: [PATCH] Fix PR middle-end/17967, remove_useless_stmts is slow From: Andrew Pinski Date: Thu, 14 Oct 2004 18:37:00 -0000 X-SW-Source: 2004-10/txt/msg01203.txt.bz2 --Apple-Mail-6--787282964 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 1258 RTH helped me find that the problem in r_u_s is that we are calling fold_stmt which is slow as there are huge number of statements in this testcase. The following patch added the calls to fold_stmt: 2004-01-10 Jan Hubicka * tree-cfg.c (remove_usless_stmts_cond): Fold statement. (remove_useless_stmts_1): Fold trees we know how to fold. If we revert this patch we actually speed up GCC for the following testcase: #define ELSEIF1 else if (!a) f(); #define ELSEIF2 ELSEIF1 else if (a) ; #define ELSEIF4 ELSEIF2 ELSEIF2 #define ELSEIF8 ELSEIF4 ELSEIF4 #define ELSEIF16 ELSEIF8 ELSEIF8 #define ELSEIF32 ELSEIF16 ELSEIF16 #define ELSEIF64 ELSEIF32 ELSEIF32 #define ELSEIF128 ELSEIF64 ELSEIF64 #define ELSEIF256 ELSEIF128 ELSEIF128 #define ELSEIF512 ELSEIF256 ELSEIF256 #define ELSEIF1024 ELSEIF512 ELSEIF512 #define ELSEIF2048 ELSEIF1024 ELSEIF1024 #define ELSEIF4096 ELSEIF2048 ELSEIF2048 void foo (int a) { int b; if (a); ELSEIF4096 } OK? Boostrapped and tested on ppc-darwin. Thanks, Andrew Pinski ChangeLog: Revert: * tree-cfg.c (remove_usless_stmts_cond): Fold statement. (remove_useless_stmts_1): Fold trees we know how to fold. Patch: --Apple-Mail-6--787282964 Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name="temp.diff.txt" Content-Disposition: attachment; filename=temp.diff.txt Content-length: 1362 Index: tree-cfg.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v retrieving revision 2.74 diff -u -p -r2.74 tree-cfg.c --- tree-cfg.c 10 Oct 2004 13:16:35 -0000 2.74 +++ tree-cfg.c 14 Oct 2004 17:59:54 -0000 @@ -1204,7 +1204,6 @@ remove_useless_stmts_cond (tree *stmt_p, else_has_label = data->has_label; data->has_label = save_has_label | then_has_label | else_has_label; - fold_stmt (stmt_p); then_clause = COND_EXPR_THEN (*stmt_p); else_clause = COND_EXPR_ELSE (*stmt_p); cond = COND_EXPR_COND (*stmt_p); @@ -1552,13 +1551,11 @@ remove_useless_stmts_1 (tree *tp, struct break; case RETURN_EXPR: - fold_stmt (tp); data->last_goto = NULL; data->may_branch = true; break; case CALL_EXPR: - fold_stmt (tp); data->last_goto = NULL; notice_special_calls (t); update_call_expr_flags (t); @@ -1568,7 +1565,6 @@ remove_useless_stmts_1 (tree *tp, struct case MODIFY_EXPR: data->last_goto = NULL; - fold_stmt (tp); op = get_call_expr_in (t); if (op) { @@ -1604,10 +1600,6 @@ remove_useless_stmts_1 (tree *tp, struct } } break; - case SWITCH_EXPR: - fold_stmt (tp); - data->last_goto = NULL; - break; default: data->last_goto = NULL; --Apple-Mail-6--787282964--