https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54089
--- Comment #86 from Alexander Klepikov <klepikov.alex+bugs at gmail dot com> --- (In reply to Oleg Endo from comment #85) >For now, can you try to run the style check script on your changes? Thank you, that's what I've been missing! > > bool > > expand_ashiftrt (rtx *operands) > > { > > int value = INTVAL (operands[2]) & 31; > ^^^^^^ > > Missing check for 'const_int' operand. See other uses of 'CONST_INT_P'. I was completely sure that condition '(match_operand:SI 2 "const_int_operand")' in define_insn_and_split guarantees that 'CONST_INT_P (operands[2]) == true'. > I think the 'define_insn "ashrsi3_libcall_collapsed"' and > 'define_insn_and_split "ashrsi3_libcall_expand"' can be merged into a single > pattern 'define_insn_and_split "ashrsi3_n_call" and the function > 'expand_ashrsi3_libcall' (the tail of the original 'expand_ashiftrt') can be > just put into the splitter code in the new "ashrsi3_n_call". > > The splitter condition should include "&& can_create_pseudo_p ()" to make > sure it's ran before register allocation. > > I think this will reduce the change set a bit and make the intention of the > patch a bit clearer. > Yes, it looks like it works in general. But first tests show that all constant dynamic shifts expand to library call for all targets, even for those with dynshift instructions. That's because 'ashrsi3_n_call' and 'ashrsi3' should check whether right shift could be expanded to individual shifts. They both should execute the code that I separated into 'expand_ashiftrt_individual' function to expand to individual shifts properly. > > +/* { dg-final { scan-assembler > > "_f_loop1_rshift:.*mov\.l\\t(\.L\[0-9\]+),(r\[0-9\]+).*sts.l\\tpr,@-r15.*(\.L\[0-9\]+):.*jsr\\t@\\2.*bf\.s\\t\\3.*\\1:\\n\\t\.long\\t___ashiftrt_r4_6.*_f_loop2_rshift:" > > { target { ! has_dyn_shift } } } } */ > > Can you try to somehow write this in a simpler way? Maybe omit some of the > register number matches, as they don't matter etc. I took a note, I'll deal with it later.