On 8/12/24 1:49 PM, Richard Sandiford wrote:
- regno = subreg_regno (x);
+ /* A paradoxical should always be REGNO (y) + 0. Using subreg_regno
+ for something like (subreg:DI (reg:SI N) 0) on a WORDS_BIG_ENDIAN
+ target will return N-1 which is catastrophic for N == 0 and just
+ wrong for other cases.
+
+ Fixing subreg_regno would be a better option, except that reload
+ depends on its current behavior. */
+ if (paradoxical_subreg_p (x))
+ regno = REGNO (y);
+ else
+ regno = subreg_regno (x);
Are you sure that's right? For a 32-bit big-endian target,
(subreg:DI (reg:SI 1) 0) really should simplify to (reg:DI 0) rather
than (reg:DI 1).
Correct, we want to get (reg:DI 0). We get "0" back from REGNO (y).
And we get 0 back from byte_lowpart_offset (remember, it's paradoxical).
The sum is 0 resulting in (reg:DI 0).
> Like you say, this leads to an invalid result for (reg:SI 0) in place
of (reg:SI 1). But AIUI, it's reload's/LRA's job to ensure that that
never happens. This is part of the reason why LRA/IRA need to track
the widest referenced mode.
So it sounds like something might have gone wrong earlier/elsewhere.
Not that I could find, but maybe I missed something. It's been a long
time since I wandered through reload.
jeff