On Mon, Mar 23, 2026 at 05:16:07PM +0530, Kishan Parmar wrote: > Hi All, > > Changes from v1: > - Corrected commit message. > > The following patch has been bootstrapped and regtested on > powerpc64le-linux. > > Thanks and regards, > Kishan Parmar > > The fallback expansion of __builtin_bswap16 on pre-Power10 used a > sequence of multiple rlwinm/or instructions: > > mr r9,r3 > rlwinm r3,r9,24,24,31 > rlwinm r10,r9,8,16,23 > or r3,r3,r10 > rlwinm r3,r3,0,0xffff > > This was functionally correct but less optimal. > > Rewrite the splitter to use a rotate-insert idiom, producing: > > mr r9,r3 > slwi r3,r9,8 > rlwimi r3,r9,24,24,31 > rlwinm r3,r3,0,0xffff > > This sequence avoids the extra mask/or operations. > > 2026-03-23 Kishan Parmar <[email protected]> > > gcc/ > PR target/121076 > * config/rs6000/rs6000.md (bswaphi2_reg): Replace > rotate-mask/rotate-mask/or sequence with shift and > rotate-mask-insert sequence. > > gcc/testsuite/ > * gcc.target/powerpc/pr121076.c: New test.
This looks ok for committing to the the master branch and back porting to the other active patches after a burn in period. -- Michael Meissner, IBM PO Box 98, Ayer, Massachusetts, USA, 01432 email: [email protected]
