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]

[3.2, mainline] fix spec2000 sixtrack misscompilation


Hi,
this patch fixes latent bug (exhibiting in 3.2.x too) that causes us to
misscompile sixtrack from SPEC2000.  The problem is that sixtrack uses global
variables as iteration counters and because of sick relation between load
motion, disabled sotre motion (enabling it makes testcase to pass) and loop
optimizer we end up with iteration variable incremented in following way:

(set (reg tmp) (plus (reg ind) (const_int 1)))
(set (reg ind) (reg tmp))

and loop decides to elliminate IND by reduing TMP into GIV.  It correctly marks
GIV to be IND+1 and emits code, however the code to increase GIV is emit before
the second instrction, so the set of IND is wrong.

Fixed by always emitting the increment after the increment of original
induction variable.

Honza

Mon Sep  2 12:06:08 CEST 2002  Jan Hubicka  <jh@suse.cz>
	* loop.c (loop_gics_reduce):  Emit addition after.
*** loop.c.old	Sun Sep  1 20:17:04 2002
--- loop.c	Sun Sep  1 20:27:29 2002
*************** loop_givs_reduce (loop, bl)
*** 4731,4737 ****
  	      rtx insert_before;
  
  	      if (! auto_inc_opt)
! 		insert_before = tv->insn;
  	      else if (auto_inc_opt == 1)
  		insert_before = NEXT_INSN (v->insn);
  	      else
--- 4731,4737 ----
  	      rtx insert_before;
  
  	      if (! auto_inc_opt)
! 		insert_before = NEXT_INSN (tv->insn);
  	      else if (auto_inc_opt == 1)
  		insert_before = NEXT_INSN (v->insn);
  	      else


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