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]

stormy16: defer negsi2 split


In stormy16, the negsi2 pattern is split into two subtracts (negsi2 ->
(0-reg) -> si:hi split).  Unfortunately, it needs to preserve the
borrow bit between these two insns, but reload might try to reload the
second subhi, and clobber the carry.  This patch modifies the negsi2
split to happen after reload instead of before, so that no reload
insns happen between the two subhi's.  Tested, no regressions.

2003-05-05  DJ Delorie  <dj@redhat.com>

	* config/stormy16/stormy16.md (negsi2): Allocate the pseudos
	before reload, but defer the split until after.
	* config/stormy16/stormy16.c (xstormy16_expand_arith): Modify
	to match.

Index: stormy16.md
===================================================================
RCS file: /cvs/uberbaum/gcc/config/stormy16/stormy16.md,v
retrieving revision 1.11
diff -p -2 -r1.11 stormy16.md
*** stormy16.md	6 Mar 2003 20:03:49 -0000	1.11
--- stormy16.md	5 May 2003 05:01:49 -0000
***************
*** 604,612 ****
  
  (define_expand "negsi2"
!   [(set (match_operand:SI 0 "register_operand" "")
! 	(neg:SI (match_operand:SI 1 "register_operand" "")))]
    ""
!   "{ xstormy16_expand_arith (SImode, NEG, operands[0], const0_rtx,
! 			    operands[1], gen_reg_rtx (BImode)); DONE; }")
  
  ;; ::::::::::::::::::::
--- 604,624 ----
  
  (define_expand "negsi2"
!   [(parallel [(set (match_operand:SI 0 "register_operand" "")
! 		   (neg:SI (match_operand:SI 1 "register_operand" "")))
! 	      (clobber (match_scratch:BI 2 ""))])]
    ""
!   "{ operands[2] = gen_reg_rtx (HImode);
!      operands[3] = gen_reg_rtx (BImode); }")
! 
! (define_insn_and_split "*negsi2_internal"
!   [(set (match_operand:SI 0 "register_operand" "=&r")
! 	(neg:SI (match_operand:SI 1 "register_operand" "r")))
!    (clobber (match_scratch:BI 2 "=y"))]
!   ""
!   "#"
!   "reload_completed"
!   [(pc)]
!   "{ xstormy16_expand_arith (SImode, NEG, operands[0], operands[0],
! 			    operands[1], operands[2]); DONE; }")
  
  ;; ::::::::::::::::::::
Index: stormy16.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/stormy16/stormy16.c,v
retrieving revision 1.38
diff -p -2 -r1.38 stormy16.c
*** stormy16.c	17 Apr 2003 10:35:08 -0000	1.38
--- stormy16.c	5 May 2003 05:01:49 -0000
*************** xstormy16_expand_arith (mode, code, dest
*** 1874,1882 ****
  
    if (code == NEG)
!     {
!       rtx zero_reg = gen_reg_rtx (word_mode);
!       emit_move_insn (zero_reg, src0);
!       src0 = zero_reg;
!     }
    
    for (i = 0; i < num_words; i++)
--- 1874,1878 ----
  
    if (code == NEG)
!     emit_move_insn (src0, const0_rtx);
    
    for (i = 0; i < num_words; i++)
*************** xstormy16_expand_arith (mode, code, dest
*** 1885,1893 ****
        rtx insn;
        
!       if (code == NEG)
! 	w_src0 = src0;
!       else
! 	w_src0 = simplify_gen_subreg (word_mode, src0, mode, 
! 				      i * UNITS_PER_WORD);
        w_src1 = simplify_gen_subreg (word_mode, src1, mode, i * UNITS_PER_WORD);
        w_dest = simplify_gen_subreg (word_mode, dest, mode, i * UNITS_PER_WORD);
--- 1881,1886 ----
        rtx insn;
        
!       w_src0 = simplify_gen_subreg (word_mode, src0, mode, 
! 				    i * UNITS_PER_WORD);
        w_src1 = simplify_gen_subreg (word_mode, src1, mode, i * UNITS_PER_WORD);
        w_dest = simplify_gen_subreg (word_mode, dest, mode, i * UNITS_PER_WORD);


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