https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87763
--- Comment #30 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Looking at rs6000, I see: *rotl<mode>3_insert and *rotl<mode>3_insert_2 patterns doing what has been discussed above (two variants for IOR operand order), *rotl<mode>3_insert_3 without one of the ANDs (not needing canonicalization), *rotl<mode>3_insert_4 with a right shift, *rotlsi3_insert_5 + *rotldi3_insert_{6,7} that match yet something, plus rs6000_is_valid_mask and rs6000_is_valid_insert_mask helpers. I'd say you could even copy and adjust those, add testcases that cover all that both in the extremely small functions like in #c21 where it might be a regression and in middle of larger code where combiner will not see hard registers around. A day of work at most for somebody familiar with the architecture.