https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121076
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by kishan parmar <[email protected]>: https://gcc.gnu.org/g:9ddcaf3528a14f44c1bfb6512a8ced8d4a89cb6f commit r17-6155-g9ddcaf3528a14f44c1bfb6512a8ced8d4a89cb6f Author: Kishan Parmar <[email protected]> Date: Thu Nov 12 12:05:27 2026 +0530 rs6000: Improve codegen for __builtin_bswap16 on GPRs [PR121076] 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-11-12 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.
