[PATCH] D152227: [X86] Prefer vmovmsk instead of vtest for alderlake.

LuoYuanke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 04:17:00 PDT 2023


LuoYuanke added inline comments.


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:47913
   // MOVMSK(PCMPEQ(X,Y)) != -1 -> !PTESTZ(XOR(X,Y),XOR(X,Y)).
   if (IsAllOf && Subtarget.hasSSE41() && IsOneUse) {
     MVT TestVT = VecVT.is128BitVector() ? MVT::v2i64 : MVT::v4i64;
----------------
LuoYuanke wrote:
> RKSimon wrote:
> > What about these folds?
> I'll take a look at it and I prefer to implement it in a separate patch if MOVMSK is better.
It seems this transform is good. If I revert the transform, I get below lit test change. 

```
-; AVX-LABEL: movmsk_or_v2i64:
-; AVX:       # %bb.0:
-; AVX-NEXT:    vpxor %xmm1, %xmm0, %xmm0
-; AVX-NEXT:    vptest %xmm0, %xmm0
-; AVX-NEXT:    setne %al
-; AVX-NEXT:    retq
+; AVX1OR2-LABEL: movmsk_or_v2i64:
+; AVX1OR2:       # %bb.0:
+; AVX1OR2-NEXT:    vpcmpeqq %xmm1, %xmm0, %xmm0
+; AVX1OR2-NEXT:    vpcmpeqd %xmm1, %xmm1, %xmm1
+; AVX1OR2-NEXT:    vtestpd %xmm1, %xmm0
+; AVX1OR2-NEXT:    setae %al
+; AVX1OR2-NEXT:    retq

```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152227



More information about the llvm-commits mailing list