public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@physics.uc.edu>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jan Hubicka <jh@suse.cz>
Subject: [PATCH] Fix PR middle-end/17967, remove_useless_stmts is slow
Date: Thu, 14 Oct 2004 18:37:00 -0000	[thread overview]
Message-ID: <FDA115AC-1E0F-11D9-9E71-000A95D692F4@physics.uc.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 1258 bytes --]

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  <jh@suse.cz>
         * 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:

[-- Attachment #2: temp.diff.txt --]
[-- Type: text/plain, Size: 1362 bytes --]

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;

             reply	other threads:[~2004-10-14 18:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-14 18:37 Andrew Pinski [this message]
2004-10-14 21:01 ` Richard Henderson
2004-10-15  4:19   ` Andrew Pinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FDA115AC-1E0F-11D9-9E71-000A95D692F4@physics.uc.edu \
    --to=pinskia@physics.uc.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jh@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).