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]

problem in reload


Hello,

I have a problem with reload and auto increment. The problem occurs when
the following insn is present (This is on the c4x target where QI = 32 bit
and HI = 64 bit):

(insn 136 132 262 (set (reg/v:HI 41)
        (mem/s:HI (post_inc:QI (reg/v:QI 39)) 0)) 288 {*movhi_noclobber} (nil)
    (expr_list:REG_INC (reg/v:QI 39)
        (nil)))

Reload converts this into a load, set with post_increment and store:

(insn 318 116 100 (set (reg:QI 8 ar0)
        (mem:QI (plus:QI (reg:QI 11 ar3)
                (const_int 1)) 0)) -1 (nil)
    (nil))

(insn 100 318 321 (set (reg/v:HI 12 ar4)
        (mem/s:HI (post_inc:QI (reg:QI 8 ar0)) 0)) 288 {*movhi_noclobber} (nil)
    (expr_list:REG_INC (reg:QI 8 ar0)
        (nil)))

(insn 321 100 104 (set (mem:QI (plus:QI (reg:QI 11 ar3)
                (const_int 1)) 0)
        (reg:QI 8 ar0)) -1 (nil)
    (nil))

Now try_split is run in reload1.c. Notice that the REG_INC is removed and the
insn is split into two increments. There is nothing special about this, this
happens also on other targets like m68k.

(insn 318 116 373 (set (reg:QI 8 ar0)
        (mem:QI (plus:QI (reg:QI 11 ar3)
                (const_int 1)) 0)) 5 {movqi_noclobber} (nil)
    (nil))

(insn 373 318 374 (set (reg:QI 12 ar4)
        (mem:QI (post_inc:QI (reg:QI 8 ar0)) 0)) 5 {movqi_noclobber} (insn_list 318 (nil))
    (nil))

(insn 374 373 321 (set (reg:QI 13 ar5)
        (mem:QI (post_inc:QI (reg:QI 8 ar0)) 0)) 5 {movqi_noclobber} (nil)
    (nil))

(insn 321 374 104 (set (mem:QI (plus:QI (reg:QI 11 ar3)
                (const_int 1)) 0)
        (reg:QI 8 ar0)) 5 {movqi_noclobber} (nil)
    (expr_list:REG_DEAD (reg:QI 8 ar0)
        (nil)))


Now the reload cse is run. First reg_values[ar0] is set to:
(mem:QI (plus:QI (reg:QI 11 ar3) (const_int 1)) 0)

Then the next two instructions are handled with their results set. After this
the final insn is checked. Now it is detected that reg_values[ar0] still has
the same value as in the first insn so this insn is removed! Oops we do not
store the incremented ar0 value anymore.
I modified reload1.c to invalidate the src when it is detected that there is
a side effect on the src (auto increment). Now the second insn will 
invalidate the set to ar0 in the first insn.

	Herman.

--- reload1.c.org	Wed Nov 11 18:46:18 1998
+++ reload1.c	Wed Nov 11 18:31:08 1998
@@ -9301,6 +9301,8 @@ reload_cse_record_set (set, body)
       || side_effects_p (dest))
     {
       reload_cse_invalidate_rtx (dest, NULL_RTX);
+      if (side_effects_p (src))
+        reload_cse_invalidate_rtx (src, NULL_RTX);
       return;
     }
 
-- 
-------------------------------------------------------------------------
Herman ten Brugge			Email:	Haj.Ten.Brugge@net.HCC.nl


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