On Wed, Sep 02, 2026 at 04:43:48PM +0530, Kishan Parmar wrote:
> Hello All,
> 
> Changes from V1:
>       * Fix formatting and indentation of new splitters in rs6000.md.
>       * Clarify comments above new splitter.
>       * Synced to master branch.
> 
> Below patch is bootstrapped and tested on powerpc64le-linux with no
> regressions.
> 
> Thank You,
> Kishan
> 
> GCC currently emits three instructions (rldic/rldic/or) for RTL of the
> form:
> 
>   (ior (and (ashift S1 sh1) mask1)
>        (and (ashift S2 sh2) mask2))
> 
> even when the two masks select disjoint bitfields that can be merged
> using a single `rldic` (rotate-and-mask) followed by an `rldimi`
> (rotate-and-insert) instruction.
> 
> This patch adds a `define_split` pattern that recognizes such cases and
> rewrites them into a two-instruction sequence that performs the same
> operation more efficiently:
> 
>     rldic  dest, S2, sh2, mb2
>     rldimi dest, S1, sh1, mb1
> 
> The splitter checks that:
>   * both rotated fields have valid insert/shift masks,
>   * the masks are non-overlapping, and
>   * safety guard to check pseudos can be created at this stage
>     (`can_create_pseudo_p()`).
> 
> This transformation allows combine to generate the higher-level
> (ior(and(rotate), and(rotate))) form, while the new splitter breaks it
> down pre-reload into efficient PowerPC field-merge instructions.
> 
> 
> 2025-09-02  Kishan Parmar  <[email protected]>
> 
> gcc/ChangeLog:
>       PR target/93171
>       * config/rs6000/rs6000.md (New merge field splitter): New define_split
>       pattern. Split disjoint rotate-and-mask OR sequences into rldic + rldimi
>       when both masks are valid and non-overlapping.
>       * testsuite/gcc.target/powerpc/pr93171.c: New testcase.

This is ok for the master branch.

-- 
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: [email protected]

Reply via email to