https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106770
--- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Surya Kumari Jangala <[email protected]>: https://gcc.gnu.org/g:4f6eeefe8d8146af48ae6526e398d3b46640822a commit r17-4647-g4f6eeefe8d8146af48ae6526e398d3b46640822a Author: Surya Kumari Jangala <[email protected]> Date: Thu Sep 24 22:20:04 2026 -0500 rs6000/p8swap: Fix incorrect lane extraction by vec_extract() [PR106770] In the routine rs6000_analyze_swaps(), special handling of swappable instructions is done even if the webs that contain the swappable instructions are not optimized, i.e., the webs do not contain any permuting load/store instructions along with the associated register swap instructions. Doing special handling in such webs will result in the extracted lane being adjusted unnecessarily for vec_extract. Another issue is that existing code treats non-permuting loads/stores as special swappables. Non-permuting loads/stores (that have not yet been split into a permuting load/store and a swap) are handled by converting them into a permuting load/store (which effectively removes the swap). As a result, if special swappables are handled only in webs containing permuting loads/stores, then non-optimal code is generated for non-permuting loads/stores. Hence, in this patch, all webs containing either permuting loads/ stores or non-permuting loads/stores are marked as requiring special handling of swappables. Swaps associated with permuting loads/stores are marked for removal, and non-permuting loads/stores are converted to permuting loads/stores. Then the special swappables in the webs are fixed up. This patch also ensures that swappable instructions are not modified in the following webs as it is incorrect to do so: - webs containing permuting load/store instructions and associated swap instructions that are transformed by converting the permuting memory instructions into non-permuting instructions and removing the swap instructions. - webs where swap(load(vector constant)) instructions are replaced with load(swapped vector constant). 2023-09-10 Surya Kumari Jangala <[email protected]> gcc: PR rtl-optimization/106770 * config/rs6000/rs6000-p8swap.cc (non_permuting_mem_insn): New function. (handle_non_permuting_mem_insn): New function. (rs6000_analyze_swaps): Handle swappable instructions only in certain webs. (web_requires_special_handling): New instance variable. (handle_special_swappables): Remove handling of non-permuting load/store instructions. gcc/testsuite: PR rtl-optimization/106770 * gcc.target/powerpc/pr106770.c: New test.
