Hi Mike, On 20/05/26 11:53 AM, Michael Meissner wrote: > On Mon, May 04, 2026 at 09:49:35AM +0530, Surya Kumari Jangala wrote: >> >> Pinging the patch. >> >>>>>>>> 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/PR106770 >>>>>>>> * 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/PR106770 >>>>>>>> * gcc.target/powerpc/pr106770.c: New test. >>>>>>>> --- >>>>>>>> > > I did notice tht when you remove the case elements in > handle_special_swappables tht if those cases show up nw, it will hit > default, and the gcc_unreachaable call will be generated, which is > reasonable. > > Note, the tests are rather tricky, and I believe they will not work > correctly if you configure the compiler to default to power9, power10, > or power11 code. > > The test has the guard condition: > > /* { dg-require-effective-target powerpc_p8vector_ok } */ > /* { dg-options "-mdejagnu-cpu=power8 -O2 " } */ > > What -mdejagnu-cpu=power8 does is tell the test compiler to use > -mcpu=power8 if the default target is not at the power8 level. If you > configure the compiler to default to power9, power10, or power11, using > -mdejagnu-cpu=power8 will not change the default. > > Given that the byte swapping vector instructions were added in power9, > if the default target is power9 or high, the p8swap support is turned > off. > > You could change the guard condition to: > > /* { dg-require-effective-target powerpc_p8vector_ok } */ > /* { dg-options "-mdejagnu-cpu=power8 -O2 " } */ > > Or add the following line (with an explanation) in the source before > the function in the test: > > #pragma GCC target ("cpu=power8")
Since Peter has confirmed (at https://gcc.gnu.org/pipermail/gcc-patches/2026-August/728012.html) that -mdejagnu-cpu overrides the --with-cpu option used to configure the compiler, there are no changes required in this patch. Can you please approve this patch for upstreaming? -Surya >
