[SLP]Skip undefs trying to find perfect/shuffled tree entries matching.
authorAlexey Bataev <a.bataev@outlook.com>
Thu, 22 Apr 2021 13:15:27 +0000 (06:15 -0700)
committerAlexey Bataev <a.bataev@outlook.com>
Thu, 22 Apr 2021 15:59:07 +0000 (08:59 -0700)
We can skip check for undefs trying to find perfect/shuffled tree
entries matching, they can be ignored completely improving the final
cost/vectorization results.

Differential Revision: https://reviews.llvm.org/D101061

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/remark_extract_broadcast.ll

index a54a0ed..2eb5b8d 100644 (file)
@@ -4308,6 +4308,8 @@ BoUpSLP::isGatherShuffledEntry(const TreeEntry *TE, SmallVectorImpl<int> &Mask,
   int NumShuffles = 0;
   for (int I = 0, E = TE->Scalars.size(); I < E; ++I) {
     Value *V = TE->Scalars[I];
+    if (isa<UndefValue>(V))
+      continue;
     const TreeEntry *VTE = getTreeEntry(V);
     if (!VTE) {
       // Check if it is used in one of the gathered entries.
index c54b682..8376def 100644 (file)
@@ -45,7 +45,7 @@ define void @fextr(i16* %ptr) {
 ; YAML-NEXT: Function:        fextr
 ; YAML-NEXT: Args:
 ; YAML-NEXT:   - String:          'Stores SLP vectorized with cost '
-; YAML-NEXT:   - Cost:            '1'
+; YAML-NEXT:   - Cost:            '-1'
 ; YAML-NEXT:   - String:          ' and with tree size '
 ; YAML-NEXT:   - TreeSize:        '4'