On 10/27/2015 06:09 PM, Jakub Jelinek wrote: > On Tue, Oct 27, 2015 at 05:47:19PM +0100, Andreas Krebbel wrote: >> Hi, >> >> what does speak against folding SUBREGs on constants in fold_rtx? >> >> CSE does refuse to propagate constants into subreg expressions probably >> because fold_rtx does not >> handle it - and in fact a subreg on a constant does not seem to be defined. >> I'm wondering why this >> is the case? What's the problem with simplifying subregs on constants? >> >> If there is a good reason not to fold things like: >> (subreg:DI (const_int 1 [0x1]) 0) > > This is invalid RTL, so it shouldn't be generated at all. > The problem is that CONST_INT has VOIDmode, and a valid SUBREG needs both > inner and outer mode to figure out which bits it is talking about. > > Therefore, wherever you end up with replacing SUBREG_REG with CONST_INT or > other modeless RTL, there is a bug; instead of that the code should be using > something like simplify_replace_rtx or simplify_replace_fn_rtx, where the > result is immediately simplified at the point where the original inner mode is > still known.
Ok. Thanks! -Andreas-