For move2add_valid_value_p we also have to ask the target whether a
register can be accessed in a different mode than it was set before.
gcc/ChangeLog:
PR rtl-optimization/100263
* postreload.c (move2add_valid_value_p): Ensure register can
change mode.
(cherry picked from commit
bb283170e7a1f39bf533651418daf10ad18eccfc)
{
scalar_int_mode old_mode;
if (!is_a <scalar_int_mode> (reg_mode[regno], &old_mode)
- || !MODES_OK_FOR_MOVE2ADD (mode, old_mode))
+ || !MODES_OK_FOR_MOVE2ADD (mode, old_mode)
+ || !REG_CAN_CHANGE_MODE_P (regno, old_mode, mode))
return false;
/* The value loaded into regno in reg_mode[regno] is also valid in
mode after truncation only if (REG:mode regno) is the lowpart of