[PATCH] D149083: [PowerPC] Optimize VPERM and fix code order for swapping vector operands on LE

Stefan Pintilie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 07:36:44 PDT 2023


stefanp added inline comments.


================
Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:10238
       NeedSwap = !NeedSwap;
     }
   }
----------------
maryammo wrote:
> stefanp wrote:
> > Now that the swap has been moved down should this also be moved down? Or at least part of it?
> > I ask because I've noticed that there are a number of tests where a new `vmr` has been introduced and I'm wondering if that's why.
> In the following code section (line 10286), it uses the `NeedSwap` to adjust the mask, so this single-use operand swap needs to happen before that. 
> You are right, there are new `vmr`s, they seem to be needed based on the new vector operand order in the `xxperm` instruction. 
I see what you are saying. However, maybe something like this will work:
```
if ((!isLittleEndian && !V2->hasOneUse() && V1->hasOneUse()) ||
        (isLittleEndian && !V1->hasOneUse() && V2->hasOneUse())) {
```
I tried the above on one of the tests with the extra copy and it seems to get rid of it. I have not tested this extensively so please make sure that I have not broken anything.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149083/new/

https://reviews.llvm.org/D149083



More information about the llvm-commits mailing list