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]

Re: -mpower4 sched2 bug miscompiles linux kernel


On Wed, Sep 11, 2002 at 12:25:58AM +0930, Alan Modra wrote:
> On Tue, Sep 10, 2002 at 10:10:13AM -0400, David Edelsohn wrote:
> > 	BTW, I do not mean exactly as I wrote in the previous, but why not
> > limit the copy_addr_to_reg only to the BLKmode case?
> 
> Hmm, and remove the src_reg and dest_reg increment, using "offset"
> similarly to the !TARGET_STRING case?  Yes, that might work well.
> It'll be some hours before I can do this, as I'm about to go to bed..

OK, I've tried the following:

	  src = adjust_address (orig_src, mode, offset);
	  dest = adjust_address (orig_dest, mode, offset);

	  if (mode == BLKmode)
	    {
	      /* Move the address into scratch registers.  The movstrsi
		 patterns require zero offset.  */
	      rtx src_reg;
	      rtx dest_reg;

	      src_reg = copy_addr_to_reg (XEXP (src, 0));
	      src = replace_equiv_address (src, src_reg);
	      dest_reg = copy_addr_to_reg (XEXP (dest, 0));
	      dest = replace_equiv_address (dest, dest_reg);
	      emit_insn ((*gen_func.movstrsi) (dest, src,
					       GEN_INT (move_bytes & 31),
					       align_rtx));
	    }
	  else
	    {
	      rtx tmp_reg = gen_reg_rtx (mode);

	      emit_insn ((*gen_func.mov) (tmp_reg, src));
	      emit_insn ((*gen_func.mov) (dest, tmp_reg));
	    }

Works OK, but tends to use more registers.  eg. the testcase code I
posted compiled with "-O2 -mstring" gives:

Above approach			Original patch
.ini:				.ini:
	ld 4,.LC0@toc(2)		ld 3,.LC0@toc(2)
	li 0,4				li 0,4
	std 27,-40(1)			ld 4,.LC1@toc(2)
	ld 27,.LC1@toc(2)		std 31,-8(1)
	addi 3,4,72			addi 31,3,40
	std 28,-32(1)			lswi 5,4,0
	std 29,-24(1)			stswi 5,31,0
	addi 28,27,32			li 9,2
	addi 29,4,40			addi 31,3,72
	lswi 5,27,0			addi 4,4,32
	stswi 5,29,0			stw 0,52(3)
	li 9,1				li 0,1
	lswi 5,28,12			lswi 5,4,12
	stswi 5,3,12			stswi 5,31,12
	stw 0,52(4)			stw 0,40(3)
	li 0,2				li 0,3
	stw 0,44(4)			ld 31,-8(1)
	li 0,3				stw 9,44(3)
	ld 27,-40(1)			stw 0,48(3)
	ld 28,-32(1)			blr
	ld 29,-24(1)
	stw 9,40(4)
	stw 0,48(4)
	blr

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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