I'm looking at a set of reloads that look like this:
(insn 238 3802 239 35 (set (reg/v:HI 175 [ ch ])
(sign_extend:HI (mem:QI (reg/v/f:HI 176 [ fmt ]) [0 S1 A8]))) 46
{extendqihi2} (nil)
(nil))
Note that the md pattern uses a "0" constraint; sign-extend is a
one-op insn.
Reloads for insn # 238
Reload 0: reload_in (HI) = (plus:HI (reg/f:HI 7 fb)
(const_int -128))
A_REGS, RELOAD_OTHER (opnum = 0)
reload_in_reg: (plus:HI (reg/f:HI 7 fb)
(const_int -128))
reload_reg_rtx: (reg:HI 4 a0)
Reload 1: A_REGS, RELOAD_FOR_OTHER_ADDRESS (opnum = 0)
reload_in_reg: (plus:HI (reg/f:HI 7 fb)
(const_int -128))
reload_reg_rtx: (reg:HI 4 a0)
Reload 2: reload_in (HI) = (mem/c:HI (plus:HI (plus:HI (reg/f:HI 7 fb)
(const_int -128))
(const_int -476)) [108 fmt+0 S2
A8])
A_REGS, RELOAD_FOR_OTHER_ADDRESS (opnum = 0), can't combine
reload_in_reg: (reg/v/f:HI 176 [ fmt ])
reload_reg_rtx: (reg:HI 5 a1)
Reload 3: reload_in (QI) = (mem:QI (reg/v/f:HI 176 [ fmt ]) [0 S1 A8])
reload_out (HI) = (mem/c:HI (plus:HI (plus:HI (reg/f:HI 7 fb)
(const_int -128))
(const_int -474)) [107 ch+0 S2 A8])
HL_REGS, RELOAD_OTHER (opnum = 0)
reload_in_reg: (mem:QI (reg/v/f:HI 176 [ fmt ]) [0 S1 A8])
reload_out_reg: (reg/v:HI 175 [ ch ])
reload_reg_rtx: (reg:HI 0 r0)
It generates insns for reloads 0, 2, and 3, but in this order:
reload 0 (OTHER) : insns 4152..4156
reload 2 (OADDR) : insn 4157
reload 3 (OTHER) : insns 4158..4159
(insn 4157 3802 4153 34 (set (reg:HI 5 a1)
(mem/c:HI (plus:HI (reg:HI 4 a0)
(const_int -476 [0xfffffffffffffe24])) [108 fmt+0 S2 A8])) 33
{movhi_op} (nil)
(nil))
(insn 4153 4157 4155 34 (set (reg:HI 4 a0)
(const_int -128 [0xffffffffffffff80])) 33 {movhi_op} (nil)
(nil))
(insn 4155 4153 4156 34 (set (reg:HI 4 a0)
(reg/f:HI 7 fb)) 33 {movhi_op} (nil)
(nil))
(insn 4156 4155 4158 34 (set (reg:HI 4 a0)
(plus:HI (reg:HI 4 a0)
(const_int -128 [0xffffffffffffff80]))) 2 {addhi3} (nil)
(expr_list:REG_EQUIV (plus:HI (reg/f:HI 7 fb)
(const_int -128 [0xffffffffffffff80]))
(nil)))
(insn 4158 4156 238 34 (set (reg:QI 0 r0)
(mem:QI (reg:HI 5 a1) [0 S1 A8])) 32 {movqi_op} (nil)
(nil))
(insn 238 4158 4159 34 (set (reg:HI 0 r0)
(sign_extend:HI (reg:QI 0 r0))) 46 {extendqihi2} (nil)
(nil))
(insn 4159 238 4160 34 (set (mem/c:HI (plus:HI (reg:HI 4 a0)
(const_int -474 [0xfffffffffffffe26])) [107 ch+0 S2 A8])
(reg:HI 0 r0)) 33 {movhi_op} (nil)
(nil))
Note that 4157 is out of order. I *think* what's happening is that
the MERGE_TO_OTHER macro isn't taking into account that if you merge
RELOAD_OTHER and RELOAD_FOR_OTHER_ADDRESS, you can't end up with a
RELOAD_OTHER.
Either that or there's an earlier bug in that reload 0 should be
RELOAD_FOR_OTHER_ADDR too. I think fixing either would solve
my problem.
Comments?