On 4/10/23 01:10, Jakub Jelinek wrote: > On Sat, Apr 08, 2023 at 06:25:32PM -0600, Jeff Law wrote: >> >> >> On 4/6/23 08:21, Eric Botcazou wrote: >> >>>> So, perhaps just in the return op0; case add further code for >>>> WORD_REGISTER_OPERATIONS and sub-word modes which will call nonzero_bits >>>> again for the word mode and decide if it is still safe. >>> >>> Does it work to just replace mode by word_mode in the calls to nonzero_bits? >> It helps marginally -- basically we defer mucking up the code a bit. We >> then hit this in simplify_and_const_int_1: >> >> >> /* See what bits may be nonzero in VAROP. Unlike the general case of >> a call to nonzero_bits, here we don't care about bits outside >> MODE. */ >> >> nonzero = nonzero_bits (varop, mode) & GET_MODE_MASK (mode); >> >> That just seems wrong for WORD_REGISTER_OPERATIONS targets. >> >> >> Hacking both locations in a similar manner fixes the test. > > If so, can you post that in patch form and can we go with that version > plus the testcase (e.g. from the first patch I've posted where I've changed > dse)? So as I mentioned in IRC, I haven't really looked closely at simplify_and_const_int_1. I don't have a high degree of confidence this patch is complete, even though it does fix the test for 108947 and 109040. I did bootstrap on riscv, but not a regression test, that's spinning right now. Jeff