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]

bug fix for merge_assigned_reloads


In SH gcc mainline, for execute/930628-1.c -O2 -m4, this instruction:

(insn 862 665 55 (set (reg:SI 216)
        (plus:SI (reg:SI 212)
            (reg:SI 313))) 23 {*addsi3_compact} (nil)
    (nil))

gets these reloads:

Reload 0: reload_in (SI) = (plus:SI (reg/f:SI 14 r14)
                                                    (const_int 444 [0x1bc]))
        GENERAL_REGS, RELOAD_FOR_OUTPUT_ADDRESS (opnum = 0)
        reload_in_reg: (plus:SI (reg/f:SI 14 r14)
                                                    (const_int 444 [0x1bc]))
Reload 1: reload_in (SI) = (plus:SI (reg/f:SI 14 r14)
                                                    (const_int 444 [0x1bc]))
        GENERAL_REGS, RELOAD_FOR_OTHER_ADDRESS (opnum = 0)
        reload_in_reg: (plus:SI (reg/f:SI 14 r14)
                                                    (const_int 444 [0x1bc]))
Reload 2: reload_in (SI) = (plus:SI (reg/f:SI 14 r14)
                                                    (const_int 444 [0x1bc]))
        GENERAL_REGS, RELOAD_FOR_INPUT_ADDRESS (opnum = 2)
        reload_in_reg: (plus:SI (reg/f:SI 14 r14)
                                                    (const_int 444 [0x1bc]))
Reload 3: reload_in (SI) = (mem:SI (plus:SI (plus:SI (reg/f:SI 14 r14)
                                                            (const_int 444 [0x
                                                        (const_int 36 [0x24]))
        reload_out (SI) = (mem:SI (plus:SI (plus:SI (reg/f:SI 14 r14)
                                                            (const_int 444 [0x
                                                        (const_int 40 [0x28]))
        GENERAL_REGS, RELOAD_OTHER (opnum = 0), can't combine
        reload_in_reg: (reg:SI 212)
        reload_out_reg: (reg:SI 216)
Reload 4: reload_in (SI) = (mem:SI (plus:SI (plus:SI (reg/f:SI 14 r14)
                                                            (const_int 444 [0x
                                                        (const_int 48 [0x30]))
        GENERAL_REGS, RELOAD_FOR_INPUT (opnum = 2), can't combine
        reload_in_reg: (reg:SI 313)

reload 3 gets r1 as reload register, all other reloads get r0.
Then merge_assigned_reloads is called.  It merges reload 1 and 2 into a
RELOAD_OTHER, but then proceeds to change reload 0 to RELOAD_OTHER,
resulting in r to be clobbered:

0x1210 <main+112>:      mov.w   0x12c0 <main+288>,r1    ! 0x1bc
0x1212 <main+114>:      add     r14,r1
0x1214 <main+116>:      mov.l   @(36,r1),r2
0x1216 <main+118>:      mov.l   @(48,r1),r1
0x1218 <main+120>:      add     r1,r2
0x121a <main+122>:      mov.l   r2,@(40,r1)


Thu May 30 19:23:18 2002  J"orn Rennecke <joern.rennecke@superh.com>

	* reload1.c (merge_assigned_reloads): Don't change reloads
	other than RELOAD_FOR_INPUT_ADDRESS / RELOAD_FOR_INPADDR_ADDRESS
	to RELOAD_OTHER when there are conflicting input reloads.

*** reload1.c-orig	Thu May 23 21:16:55 2002
--- reload1.c	Thu May 30 19:24:18 2002
*************** merge_assigned_reloads (insn)
*** 6098,6108 ****
--- 6098,6116 ----
  	     if they were for inputs, RELOAD_OTHER for outputs.  Note that
  	     this test is equivalent to looking for reloads for this operand
  	     number.  */
+ 	  /* We must take special care when there are two or more reloads to
+ 	     be merged and a RELOAD_FOR_OUTPUT_ADDRESS reload that loads the
+ 	     same value or a part of it; we must not change its type if there
+ 	     is a conflicting input.  */
  
  	  if (rld[i].when_needed == RELOAD_OTHER)
  	    for (j = 0; j < n_reloads; j++)
  	      if (rld[j].in != 0
  		  && rld[j].when_needed != RELOAD_OTHER
+ 		  && rld[j].when_needed != RELOAD_FOR_OTHER_ADDRESS
+ 		  && (! conflicting_input
+ 		      || rld[j].when_needed == RELOAD_FOR_INPUT_ADDRESS
+ 		      || rld[j].when_needed == RELOAD_FOR_INPADDR_ADDRESS)
  		  && reg_overlap_mentioned_for_reload_p (rld[j].in,
  							 rld[i].in))
  		rld[j].when_needed


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