This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] tree-ssa-dom.c: Speed up thread_across_edge.


Hi,

Attached is a patch to speed up thread_across_edge.

Consider

  cached_lhs = local_fold (COND_EXPR_COND (dummy_cond));
  if (! is_gimple_min_invariant (cached_lhs))
    cached_lhs = lookup_avail_expr (dummy_cond, false);
  if (!cached_lhs || ! is_gimple_min_invariant (cached_lhs))
    {
      cached_lhs = simplify_cond_and_lookup_avail_expr (dummy_cond,
							NULL,
							false);
    }

Note that the statement inside the second "if" is executed only when
local_fold fails to produce a gimple min invariant.  In other words,
if the condition in the first "if" is false, we have a nonzero
cached_lhs and a gimple min invariant.

The patch manually performs jump threading.

The resulting code makes sense conceptually, too.  If we already have
a gimple min variant, why do we want to continue to poke at it?

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2004-12-10  Kazu Hirata  <kazu@cs.umass.edu>

	* tree-ssa-dom.c (thread_across_edge): Speed up by avoiding a
	call to is_gimple_min_invariant if we know the result.

Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.73
diff -c -d -p -r2.73 tree-ssa-dom.c
*** tree-ssa-dom.c	3 Dec 2004 07:38:39 -0000	2.73
--- tree-ssa-dom.c	9 Dec 2004 18:25:00 -0000
*************** thread_across_edge (struct dom_walk_data
*** 745,756 ****
  	     otherwise look it up in the hash tables.  */
  	  cached_lhs = local_fold (COND_EXPR_COND (dummy_cond));
  	  if (! is_gimple_min_invariant (cached_lhs))
- 	    cached_lhs = lookup_avail_expr (dummy_cond, false);
-  	  if (!cached_lhs || ! is_gimple_min_invariant (cached_lhs))
  	    {
! 	      cached_lhs = simplify_cond_and_lookup_avail_expr (dummy_cond,
! 								NULL,
! 								false);
  	    }
  	}
        /* We can have conditionals which just test the state of a
--- 745,756 ----
  	     otherwise look it up in the hash tables.  */
  	  cached_lhs = local_fold (COND_EXPR_COND (dummy_cond));
  	  if (! is_gimple_min_invariant (cached_lhs))
  	    {
! 	      cached_lhs = lookup_avail_expr (dummy_cond, false);
! 	      if (!cached_lhs || ! is_gimple_min_invariant (cached_lhs))
! 		cached_lhs = simplify_cond_and_lookup_avail_expr (dummy_cond,
! 								  NULL,
! 								  false);
  	    }
  	}
        /* We can have conditionals which just test the state of a


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]