> If we want to fix it in the combiner, I think the fix would be following. > The optimization is about > (and:SI (subreg:SI (reg:HI xxx) 0) (const_int 0x84c)) > and IMHO we can only optimize it into > (subreg:SI (and:HI (reg:HI xxx) (const_int 0x84c)) 0) > if we know that the upper bits of the REG are zeros. The reasoning is that, for WORD_REGISTER_OPERATIONS, the subword AND operation is done on the full word register, in other words that it's in effect: (subreg:SI (and:SI (reg:SI xxx) (const_int 0x84c)) 0) that is equivalent to the initial RTL so correct for WORD_REGISTER_OPERATIONS. > Now, this patch fixes the PR, but certainly generates worse (but correct) > code than the dse.cc patch. So perhaps we want both of them? What happens if you disable the step I mentioned (patchlet attached)? > As before, I unfortunately can't test it on riscv-linux (could perhaps try > that on sparc-solaris on GCC Farm which is another WORD_REGISTER_OPERATIONS > target, but last my bootstrap attempt there failed miserably because of the > Don't bootstrap at midnight issue in cp/Make-lang.in; I'll post a patch > for that once I test it). I think that we have one in the Ada compiler too; glad to know we are not alone in this boat. ;-) -- Eric Botcazou