Make sched-ebb use cselib

Bernd Schmidt bernds@redhat.com
Wed Aug 8 03:29:00 GMT 2001


One of the more interesting "features" of ia64 is the lack of usable
addressing modes.  There is no reg + offset addressing, and this reduces
the ability of gcc's alias analysis to determine even in simple cases
that two memory accesses don't conflict.
This patch is an attempt to reduce the problem.  We now use cselib to
keep track of register contents; alias.c already knows how to deal with
VALUE rtxs.

Tested like the previous patches (this is the one that actually puts it
all together).


Bernd

	* sched-deps.c: Include "cselib.h".
	(add_insn_mem_dependence, sched_analyze_1, sched_analyze_2):
	Use cselib to turn memory addresses into VALUEs.
	(sched_analyze): Call cselib_init/cselib_finish if necessary.
	* sched-int.h (struct sched_info): New member USE_CSELIB.
	* sched-ebb.c (ebb_sched_info): Initialize it.
	* sched-rgn.c (rgn_sched_info): Likewise.
	* Makefile.in (sched-deps.o): Update dependencies.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.716
diff -c -p -r1.716 Makefile.in
*** Makefile.in	2001/08/06 21:07:40	1.716
--- Makefile.in	2001/08/08 10:25:03
*************** haifa-sched.o : haifa-sched.c $(CONFIG_H
*** 1529,1535 ****
     $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h $(TM_P_H)
  sched-deps.o : sched-deps.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) sched-int.h \
     $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h function.h \
!    $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h $(TM_P_H)
  sched-rgn.o : sched-rgn.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) sched-int.h \
     $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h function.h \
     $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h $(TM_P_H)
--- 1529,1535 ----
     $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h $(TM_P_H)
  sched-deps.o : sched-deps.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) sched-int.h \
     $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h function.h \
!    $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h cselib.h $(PARAMS_H) $(TM_P_H)
  sched-rgn.o : sched-rgn.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) sched-int.h \
     $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h flags.h insn-config.h function.h \
     $(INSN_ATTR_H) toplev.h $(RECOG_H) except.h $(TM_P_H)
Index: sched-deps.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/sched-deps.c,v
retrieving revision 1.20
diff -c -p -r1.20 sched-deps.c
*** sched-deps.c	2001/08/07 20:24:08	1.20
--- sched-deps.c	2001/08/08 10:09:32
*************** the Free Software Foundation, 59 Temple
*** 39,44 ****
--- 39,45 ----
  #include "recog.h"
  #include "sched-int.h"
  #include "params.h"
+ #include "cselib.h"

  extern char *reg_known_equiv_p;
  extern rtx *reg_known_value;
*************** add_insn_mem_dependence (deps, insn_list
*** 482,487 ****
--- 483,493 ----
    link = alloc_INSN_LIST (insn, *insn_list);
    *insn_list = link;

+   if (current_sched_info->use_cselib)
+     {
+       mem = shallow_copy_rtx (mem);
+       XEXP (mem, 0) = cselib_subst_to_values (XEXP (mem, 0));
+     }
    link = alloc_EXPR_LIST (VOIDmode, mem, *mem_list);
    *mem_list = link;

*************** sched_analyze_1 (deps, x, insn)
*** 676,681 ****
--- 682,695 ----
    else if (GET_CODE (dest) == MEM)
      {
        /* Writing memory.  */
+       rtx t = dest;
+
+       if (current_sched_info->use_cselib)
+ 	{
+ 	  t = shallow_copy_rtx (dest);
+ 	  cselib_lookup (XEXP (t, 0), Pmode, 1);
+ 	  XEXP (t, 0) = cselib_subst_to_values (XEXP (t, 0));
+ 	}

        if (deps->pending_lists_length > MAX_PENDING_LIST_LENGTH)
  	{
*************** sched_analyze_1 (deps, x, insn)
*** 695,701 ****
  	  pending_mem = deps->pending_read_mems;
  	  while (pending)
  	    {
! 	      if (anti_dependence (XEXP (pending_mem, 0), dest))
  		add_dependence (insn, XEXP (pending, 0), REG_DEP_ANTI);

  	      pending = XEXP (pending, 1);
--- 709,715 ----
  	  pending_mem = deps->pending_read_mems;
  	  while (pending)
  	    {
! 	      if (anti_dependence (XEXP (pending_mem, 0), t))
  		add_dependence (insn, XEXP (pending, 0), REG_DEP_ANTI);

  	      pending = XEXP (pending, 1);
*************** sched_analyze_1 (deps, x, insn)
*** 706,712 ****
  	  pending_mem = deps->pending_write_mems;
  	  while (pending)
  	    {
! 	      if (output_dependence (XEXP (pending_mem, 0), dest))
  		add_dependence (insn, XEXP (pending, 0), REG_DEP_OUTPUT);

  	      pending = XEXP (pending, 1);
--- 720,726 ----
  	  pending_mem = deps->pending_write_mems;
  	  while (pending)
  	    {
! 	      if (output_dependence (XEXP (pending_mem, 0), t))
  		add_dependence (insn, XEXP (pending, 0), REG_DEP_OUTPUT);

  	      pending = XEXP (pending, 1);
*************** sched_analyze_2 (deps, x, insn)
*** 838,849 ****
  	/* Reading memory.  */
  	rtx u;
  	rtx pending, pending_mem;

  	pending = deps->pending_read_insns;
  	pending_mem = deps->pending_read_mems;
  	while (pending)
  	  {
! 	    if (read_dependence (XEXP (pending_mem, 0), x))
  	      add_dependence (insn, XEXP (pending, 0), REG_DEP_ANTI);

  	    pending = XEXP (pending, 1);
--- 852,870 ----
  	/* Reading memory.  */
  	rtx u;
  	rtx pending, pending_mem;
+ 	rtx t = x;

+ 	if (current_sched_info->use_cselib)
+ 	  {
+ 	    t = shallow_copy_rtx (t);
+ 	    cselib_lookup (XEXP (t, 0), Pmode, 1);
+ 	    XEXP (t, 0) = cselib_subst_to_values (XEXP (t, 0));
+ 	  }
  	pending = deps->pending_read_insns;
  	pending_mem = deps->pending_read_mems;
  	while (pending)
  	  {
! 	    if (read_dependence (XEXP (pending_mem, 0), t))
  	      add_dependence (insn, XEXP (pending, 0), REG_DEP_ANTI);

  	    pending = XEXP (pending, 1);
*************** sched_analyze_2 (deps, x, insn)
*** 855,861 ****
  	while (pending)
  	  {
  	    if (true_dependence (XEXP (pending_mem, 0), VOIDmode,
! 				 x, rtx_varies_p))
  	      add_dependence (insn, XEXP (pending, 0), 0);

  	    pending = XEXP (pending, 1);
--- 876,882 ----
  	while (pending)
  	  {
  	    if (true_dependence (XEXP (pending_mem, 0), VOIDmode,
! 				 t, rtx_varies_p))
  	      add_dependence (insn, XEXP (pending, 0), 0);

  	    pending = XEXP (pending, 1);
*************** sched_analyze (deps, head, tail)
*** 1237,1242 ****
--- 1258,1266 ----
    register rtx u;
    rtx loop_notes = 0;

+   if (current_sched_info->use_cselib)
+     cselib_init ();
+
    for (insn = head;; insn = NEXT_INSN (insn))
      {
        if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN)
*************** sched_analyze (deps, head, tail)
*** 1386,1393 ****
  	  CONST_OR_PURE_CALL_P (loop_notes) = CONST_OR_PURE_CALL_P (insn);
  	}

        if (insn == tail)
! 	return;
      }
    abort ();
  }
--- 1410,1423 ----
  	  CONST_OR_PURE_CALL_P (loop_notes) = CONST_OR_PURE_CALL_P (insn);
  	}

+       if (current_sched_info->use_cselib)
+ 	cselib_process_insn (insn);
        if (insn == tail)
! 	{
! 	  if (current_sched_info->use_cselib)
! 	    cselib_finish ();
! 	  return;
! 	}
      }
    abort ();
  }
Index: sched-ebb.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/sched-ebb.c,v
retrieving revision 1.3
diff -c -p -r1.3 sched-ebb.c
*** sched-ebb.c	2001/08/07 20:24:08	1.3
--- sched-ebb.c	2001/08/08 10:09:32
*************** static struct sched_info ebb_sched_info
*** 193,199 ****

    NULL, NULL,
    NULL, NULL,
!   0
  };

  /* Schedule a single extended basic block, defined by the boundaries HEAD
--- 193,199 ----

    NULL, NULL,
    NULL, NULL,
!   0, 1
  };

  /* Schedule a single extended basic block, defined by the boundaries HEAD
Index: sched-int.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/sched-int.h,v
retrieving revision 1.9
diff -c -p -r1.9 sched-int.h
*** sched-int.h	2001/07/26 13:59:22	1.9
--- sched-int.h	2001/08/08 10:09:33
*************** struct sched_info
*** 146,152 ****
    rtx head, tail;

    /* If nonzero, enables an additional sanity check in schedule_block.  */
!   int queue_must_finish_empty;
  };

  extern struct sched_info *current_sched_info;
--- 146,157 ----
    rtx head, tail;

    /* If nonzero, enables an additional sanity check in schedule_block.  */
!   unsigned int queue_must_finish_empty:1;
!   /* Nonzero if we should use cselib for better alias analysis.  This
!      must be 0 if the dependency information is used after sched_analyze
!      has completed, e.g. if we're using it to initialize state for successor
!      blocks in region scheduling.  */
!   unsigned int use_cselib:1;
  };

  extern struct sched_info *current_sched_info;
Index: sched-rgn.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/sched-rgn.c,v
retrieving revision 1.12
diff -c -p -r1.12 sched-rgn.c
*** sched-rgn.c	2001/08/07 20:24:08	1.12
--- sched-rgn.c	2001/08/08 10:09:41
*************** static struct sched_info region_sched_in
*** 2352,2358 ****

    NULL, NULL,
    NULL, NULL,
!   0
  };

  /* Add dependences so that branches are scheduled to run last in their
--- 2352,2358 ----

    NULL, NULL,
    NULL, NULL,
!   0, 0
  };

  /* Add dependences so that branches are scheduled to run last in their



More information about the Gcc-patches mailing list