https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105991
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Roger Sayle <sa...@gcc.gnu.org>: https://gcc.gnu.org/g:4306339798b6843937c628c5ece8c234b309b13d commit r13-1191-g4306339798b6843937c628c5ece8c234b309b13d Author: Roger Sayle <ro...@nextmovesoftware.com> Date: Wed Jun 22 00:08:56 2022 +0100 PR target/105991: Recognize PLUS and XOR forms of rldimi in rs6000.md. This patch addresses PR target/105991 where a change to prefer representing shifts and adds at the tree-level as multiplications, causes problems for the rldimi patterns in the powerpc backend. The issue is that rs6000.md models this pattern using IOR, and some variants that have the equivalent PLUS or XOR in the RTL fail to match some *rotl<mode>4_insert patterns. This is fixed in this patch by adding a define_insn_and_split to locally canonicalize the PLUS and XOR forms to the backend's preferred IOR form. An alternative fix might be for the RTL optimizers to define a canonical form for these plus_xor_ior equivalent expressions, but the logical choice might be plus (which may appear in an addressing mode), and such a change may require a number of tweaks to update various backends (i.e. a more intrusive change than the one proposed here). Many thanks for Marek Polacek for bootstrapping and regression testing this change without problems. 2022-06-22 Roger Sayle <ro...@nextmovesoftware.com> Marek Polacek <pola...@redhat.com> Segher Boessenkool <seg...@kernel.crashing.org> Kewen Lin <li...@linux.ibm.com> gcc/ChangeLog PR target/105991 * config/rs6000/rs6000.md (rotl<mode>3_insert_3): Check that exact_log2 doesn't return -1 (or zero). (plus_xor): New code iterator. (*rotl<mode>3_insert_3_<code>): New define_insn_and_split. gcc/testsuite/ChangeLog PR target/105991 * gcc.target/powerpc/pr105991.c: New test case.