This is the mail archive of the gcc@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]

Reload problem


Hi,

This is related to PR optimization/10392, a regression on SH.


We have, at the beginning of reload, after elimination:

(mem/s:SI (plus:SI (plus:SI (reg:SI 1 r1 [174])
                    (reg/f:SI 14 r14))
                (const_int 128 [0x80])

which is then passed to find_reloads_address. After canonical regrouping

(mem/s:SI (plus:SI (plus:SI (reg:SI 1 r1 [174])
                                (const_int 128 [0x80]))
                         (reg/f:SI 14 r14))

and

(plus:SI (reg:SI 1 r1 [174])
         (const_int 128 [0x80]))

is passed to find_reloads_address_part, which doesn't modify it and calls 
push_reload on it.


Now r1 dies in the insn so push_reload schedules r1 to be the reload 
register. And eventually gen_reload tries to build the insn. However

(set (reg:SI r1) (plus:SI (reg:SI 1 r1 [174])
         (const_int 128 [0x80]))

is not a valid insn since the constant 128 is out-of-range (-128..127).

But gen_reload thinks this failed because we have three different operands 
and a two-address 'add' pattern. So it loads the constant into the reload 
register and then add the remaining register to the reload register. But the 
reload register is live before the insn so its value is overwritten.


I think there are two problems:
- (const_int 128 [0x80])) should have been scheduled for reload, but 
find_reloads_address_part is not prepared to do it because it only checks 
LEGITIMATE_CONSTANT_P,
- gen_reload expects a three operands expression but it is short-circuited by 
push_reload.

Which one should be addressed in order to fix reload?

-- 
Eric Botcazou


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