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]

sched-deps.c patch for ia64-linux misschedule of predicated insns


This fixes the ia64-linux bug mentioned by William Nuesser of SAP on
the gcc list recently.  A testcase was provided to me in private mail.
I don't know if I have permission to post it, so I am assuming no.

The simplied testcase looks something like this:
    foo = 0;
    for (;;;)
      {
	if (! foo)
	  foo = 1;
	else
	  {
	  ...
	  }
      }
foo is allocated to a predicate register, and the if-then-else is predicated
giving something like
	cmp.ne p8, p9 = r0, r0 # p8 = 0
loop:
	(p8) ...
	(p8) ...
	(p9) cmp.eq p8, p9 = r0, r0 # p8 = 1
The scheduler then switched the order of the last two instructions, not
noticing that there is a data dependence.

This was tested by a ia64-linux bootstrap.  The bootstrap died building
libjava due to a problem with an emit-rtl.c (set_mem_alias_set) change
that Kenner made today.  I haven't looked at why yet, but everything
else built OK, so I believe the patch is OK.

2001-10-01  Jim Wilson  <wilson@redhat.com>

	* sched-deps.c (add_dependence): When elide conditional dependence,
	check that insn doesn't modify cond2.

Index: sched-deps.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sched-deps.c,v
retrieving revision 1.25
diff -p -r1.25 sched-deps.c
*** sched-deps.c	2001/09/14 11:05:39	1.25
--- sched-deps.c	2001/10/02 01:10:42
*************** add_dependence (insn, elem, dep_type)
*** 222,228 ****
        cond2 = get_condition (elem);
        if (cond1 && cond2
  	  && conditions_mutex_p (cond1, cond2)
! 	  && !modified_in_p (cond1, elem))
  	return;
      }
  
--- 222,233 ----
        cond2 = get_condition (elem);
        if (cond1 && cond2
  	  && conditions_mutex_p (cond1, cond2)
! 	  /* Make sure first instruction doesn't affect condition of second
! 	     instruction if switched.  */
! 	  && !modified_in_p (cond1, elem)
! 	  /* Make sure second instruction doesn't affect condition of first
! 	     instruction if switched.  */
! 	  && !modified_in_p (cond2, insn))
  	return;
      }
  


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