This is the mail archive of the gcc-bugs@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]

Re: optimization bug


I have a patch that fixes the problem by eliminating the unnecessary USE
insns.  I am not sure how safe this patch is though.  Modifying combine to
increment REG_N_REFS if it emits a USE insn is much safer, but may result
is poorer code because of its affect on register allocation.

There are two separate bugs here that needed to be fixed to make the testcase
work.

Tue Sep 23 12:57:35 1997  Jim Wilson  <wilson@cygnus.com>

	* combine.c (try_combine): When setting elim_i2, check whether newi2pat
	sets i2dest.  When calling distribute_notes for i3dest_killed, pass
	elim_i2 and elim_i1.

Index: combine.c
===================================================================
RCS file: /cvs/cvsfiles/egcs/gcc/combine.c,v
retrieving revision 1.3
diff -p -r1.3 combine.c
*** combine.c	1997/09/22 17:41:11	1.3
--- combine.c	1997/09/23 19:56:48
*************** try_combine (i3, i2, i1)
*** 2134,2141 ****
      rtx i3links, i2links, i1links = 0;
      rtx midnotes = 0;
      register int regno;
!     /* Compute which registers we expect to eliminate.  */
!     rtx elim_i2 = (newi2pat || i2dest_in_i2src || i2dest_in_i1src
  		   ? 0 : i2dest);
      rtx elim_i1 = i1 == 0 || i1dest_in_i1src ? 0 : i1dest;
  
--- 2134,2143 ----
      rtx i3links, i2links, i1links = 0;
      rtx midnotes = 0;
      register int regno;
!     /* Compute which registers we expect to eliminate.  newi2pat may be setting
!        either i3dest or i2dest, so we must check it.  */
!     rtx elim_i2 = ((newi2pat && reg_set_p (i2dest, newi2pat))
! 		   || i2dest_in_i2src || i2dest_in_i1src
  		   ? 0 : i2dest);
      rtx elim_i1 = i1 == 0 || i1dest_in_i1src ? 0 : i1dest;
  
*************** try_combine (i3, i2, i1)
*** 2298,2304 ****
  	distribute_notes (gen_rtx (EXPR_LIST, REG_DEAD, i3dest_killed,
  				   NULL_RTX),
  			  NULL_RTX, i3, newi2pat ? i2 : NULL_RTX,
! 			  NULL_RTX, NULL_RTX);
        }
  
      /* For I2 and I1, we have to be careful.  If NEWI2PAT exists and sets
--- 2300,2306 ----
  	distribute_notes (gen_rtx (EXPR_LIST, REG_DEAD, i3dest_killed,
  				   NULL_RTX),
  			  NULL_RTX, i3, newi2pat ? i2 : NULL_RTX,
! 			  elim_i2, elim_i1);
        }
  
      /* For I2 and I1, we have to be careful.  If NEWI2PAT exists and sets


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