Im writing to you with respect to some strange SMS functionality.
In the code bellow there are 2 instructions (a builtin store and a builtin 
load) 
as they appear in the program flow before SMS:

(insn 134 133 135 12 tdscdma_pfu_ccdec.c:289 
        (set (mem:HI (plus:PSI (reg/v/f:PSI 185 [ ccdecInterim_pi16 ])
                (reg:SI 303)) [0 S2 A16])
        (unspec:HI [
                (reg/v:HI 244 [ outData_u16 ])
            ] 1752)) 1377 {INSN_BUILTIN___storebyteofs_16} (expr_list:REG_DEAD 
(reg:SI 303)
        (expr_list:REG_DEAD (reg/v:HI 244 [ outData_u16 ])
            (nil))))

(insn 136 135 137 12 tdscdma_pfu_ccdec.c:292 
        (set (reg/v:HI 248 [ mappingAddress_i16 ])
        (unspec:HI [
                (mem:HI (plus:PSI (reg/v/f:PSI 170 [ curMappingTable_pi16 ])
                        (reg:SI 305)) [0 S2 A16])
            ] 696)) 755 {INSN_BUILTIN___loadbyteofs_16} (expr_list:REG_DEAD 
(reg:SI 305)
        (nil)))

I observed that in ddg.c there are 3 dependencies build between insn 134 and 
136:
1. (T,0) - a true dep of distance 0.
2. (T,1) - a true dep of distance 1.
3. (A,1) - an anti dep of distance 1.

Due to (T,1) dependence, further on during the calling of generate_reg_moves:

1. there is created a (modulo expansion) move instruction
  (insn 207 132 134 13 (set (reg:HI 326)
        (mem:HI (plus:PSI (reg/v/f:PSI 185 [ ccdecInterim_pi16 ])
                (reg:SI 303)) [0 S2 A16])) -1 (nil))

2. while generate_reg_moves attempts to replace in insn 136 the memory access 
 (mem:HI (plus:PSI (reg/v/f:PSI 170 [ curMappingTable_pi16 ])
                        (reg:SI 305)) [0 S2 A16])

with the register (reg:HI 326) (the same as the one set by insn 207).
But the replacement fails so insn 136 remains unchanged.
Remark that later on insn 207 gets removed (during ira) 

Issues:
1.      What is the reason why (T,1) is build up? – to me it seams that (T,0) 
        must be enough
2.      Looking inside generate_reg_moves it seams to me that this function 
        is not meant to deal with replacing memory accesses but only with 
        register replacements. (see inside the call to replace_rtx which in 
        my case trys to replace the  mem accesses inside 136).

3. The (T,1) dep is assumed to take place as if before the SMS pass, 
insn 136 was preceding insn 134:

(insn 136 135 137 12 tdscdma_pfu_ccdec.c:292 
        (set (reg/v:HI 248 [ mappingAddress_i16 ])
        (unspec:HI [
                (mem:HI (plus:PSI (reg/v/f:PSI 170 [ curMappingTable_pi16 ])
                        (reg:SI 305)) [0 S2 A16])
            ] 696)) 755 {INSN_BUILTIN___loadbyteofs_16} (expr_list:REG_DEAD 
(reg:SI 305)
        (nil)))

(insn 134 133 135 12 tdscdma_pfu_ccdec.c:289 
        (set (mem:HI (plus:PSI (reg/v/f:PSI 185 [ ccdecInterim_pi16 ])
                (reg:SI 303)) [0 S2 A16])
        (unspec:HI [
                (reg/v:HI 244 [ outData_u16 ])
            ] 1752)) 1377 {INSN_BUILTIN___storebyteofs_16} (expr_list:REG_DEAD 
(reg:SI 303)
        (expr_list:REG_DEAD (reg/v:HI 244 [ outData_u16 ])
      (nil))))

If that would be the case then between 134 and 136 there would be present 
also an antidependence of distance 0. Becasue in the pipelined schedule, 
134 is scheduled before 136 (SCHED_TIME (136) > SCHED_TIME (134)) the modulo 
variable expansion needs to take place as explained before. 
 
SMS decides to produce a modulo variable expansion in a case when is not 
needed. However, it fails in fulfilling the whole modulo variable expansion
procedure, covering in this way the possibly incorrect behavior described above.

regards,
Alex

Reply via email to